This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/7080] New: when use getnameinfo() with both nodename and servname were null,[EAI_NONAME] should be returned
- From: "yanghy at cn dot fujitsu dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 8 Dec 2008 02:52:54 -0000
- Subject: [Bug libc/7080] New: when use getnameinfo() with both nodename and servname were null,[EAI_NONAME] should be returned
- Reply-to: sourceware-bugzilla at sourceware dot org
RFC 3493 said:
[EAI_NONAME] The name does not resolve for the supplied parameters.
NI_NAMEREQD is set and the host's name cannot be
located, or both nodename and servname were null.
when use getnameinfo() with both nodename and servname were null,Glibc
do not return [EAI_NONAME].It didn't check if the args both were null.
Here is an attached patch:
---
getnameinfo.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/getnameinfo.c b/getnameinfo.c
index f172fda..c06613c 100644
--- a/getnameinfo.c
+++ b/getnameinfo.c
@@ -198,6 +198,9 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen,
char *host,
return EAI_FAMILY;
}
+ if (host == NULL && serv == NULL)
+ return EAI_NONAME;
+
if (host != NULL && hostlen > 0)
switch (sa->sa_family)
{
--
1.5.3.8
--
Summary: when use getnameinfo() with both nodename and servname
were null,[EAI_NONAME] should be returned
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: yanghy at cn dot fujitsu dot com
CC: glibc-bugs at sources dot redhat dot com,yanghy at cn
dot fujitsu dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=7080
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.