a27cc8
Upstream commits:
a27cc8
a27cc8
commit a071766ebfd853179ac39f9773f894029bf86d36
a27cc8
Author: Andreas Schwab <schwab@suse.de>
a27cc8
Date:   Thu Mar 20 15:05:25 2014 +0100
a27cc8
a27cc8
    Fix use of half-initialized result in getaddrinfo when using nscd (bug 16743)
a27cc8
    
a27cc8
    This fixes a bug in the way the results from __nscd_getai are collected:
a27cc8
    for every returned result a new entry is first added to the
a27cc8
    gaih_addrtuple list, but if that result doesn't match the request this
a27cc8
    entry remains uninitialized.  So for this non-matching result an extra
a27cc8
    result with uninitialized content is returned.
a27cc8
    
a27cc8
    To reproduce (with nscd running):
a27cc8
    
a27cc8
        $ getent ahostsv4 localhost
a27cc8
        127.0.0.1       STREAM localhost
a27cc8
        127.0.0.1       DGRAM
a27cc8
        127.0.0.1       RAW
a27cc8
        (null)          STREAM
a27cc8
        (null)          DGRAM
a27cc8
        (null)          RAW
a27cc8
a27cc8
commit 8dc9751764eb1bedf06d19695524b31a16773413
a27cc8
Author: Andreas Schwab <schwab@suse.de>
a27cc8
Date:   Wed May 7 11:47:20 2014 +0200
a27cc8
a27cc8
    Fix parsing of getai result from nscd for IPv6-only request
a27cc8
a27cc8
a27cc8
Index: b/sysdeps/posix/getaddrinfo.c
a27cc8
===================================================================
a27cc8
--- a/sysdeps/posix/getaddrinfo.c
a27cc8
+++ b/sysdeps/posix/getaddrinfo.c
a27cc8
@@ -725,6 +725,18 @@ gaih_inet (const char *name, const struc
a27cc8
 		    {
a27cc8
 		      socklen_t size = (air->family[i] == AF_INET
a27cc8
 					? INADDRSZ : IN6ADDRSZ);
a27cc8
+
a27cc8
+		      if (!((air->family[i] == AF_INET
a27cc8
+			     && req->ai_family == AF_INET6
a27cc8
+			     && (req->ai_flags & AI_V4MAPPED) != 0)
a27cc8
+			    || req->ai_family == AF_UNSPEC
a27cc8
+			    || air->family[i] == req->ai_family))
a27cc8
+			{
a27cc8
+			  /* Skip over non-matching result.  */
a27cc8
+			  addrs += size;
a27cc8
+			  continue;
a27cc8
+			}
a27cc8
+
a27cc8
 		      if (*pat == NULL)
a27cc8
 			{
a27cc8
 			  *pat = addrfree++;