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 1/2]glibc:fix return value when use getnameinfo() with unspecified ipv6 address


RFC 3493:If the address is the IPv6 unspecified 
         address ("::"), a lookup is not performed,
         and the [EAI_NONAME] error is returned.
But when we used getnameinfo() with unspecified ipv6 address,
unexpected zero was returned.

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com>

---
 getnameinfo.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/getnameinfo.c b/getnameinfo.c
index 5024038..f172fda 100644
--- a/getnameinfo.c
+++ b/getnameinfo.c
@@ -191,6 +191,8 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
     case AF_INET6:
       if (addrlen < sizeof (struct sockaddr_in6))
 	return EAI_FAMILY;
+      if (IN6_IS_ADDR_UNSPECIFIED(&((const struct sockaddr_in6 *) sa)->sin6_addr))
+        return EAI_NONAME;
       break;
     default:
       return EAI_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]