This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]