olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1324568.patch

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