This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[PATCH 2/2]glibc:fix return value when use getnameinfo() with both nodename and servname were null
- From: Yang Hongyang <yanghy at cn dot fujitsu dot com>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 05 Aug 2008 13:16:11 +0800
- Subject: [PATCH 2/2]glibc:fix return value when use getnameinfo() with both nodename and servname were null
RFC 3493: The arguments node and service cannot both be NULL.
[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 we use getnameinfo() with both nodename and servname were null,
unexpected zero is returned.
Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com>
---
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