diff options
author | Andreas Schwab <schwab@suse.de> | 2014-03-20 15:05:25 +0100 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 2014-03-24 16:51:53 +0100 |
commit | a071766ebfd853179ac39f9773f894029bf86d36 (patch) | |
tree | 4c681c9798c67c68d7c09b8e09ee33fd4a96c37b /sysdeps/posix | |
parent | 27c673b8de3072caf35bc795aa1cd77a7ca18771 (diff) | |
download | glibc-a071766ebfd853179ac39f9773f894029bf86d36.tar.gz glibc-a071766ebfd853179ac39f9773f894029bf86d36.tar.xz glibc-a071766ebfd853179ac39f9773f894029bf86d36.zip |
Fix use of half-initialized result in getaddrinfo when using nscd (bug 16743)
This fixes a bug in the way the results from __nscd_getai are collected: for every returned result a new entry is first added to the gaih_addrtuple list, but if that result doesn't match the request this entry remains uninitialized. So for this non-matching result an extra result with uninitialized content is returned. To reproduce (with nscd running): $ getent ahostsv4 localhost 127.0.0.1 STREAM localhost 127.0.0.1 DGRAM 127.0.0.1 RAW (null) STREAM (null) DGRAM (null) RAW
Diffstat (limited to 'sysdeps/posix')
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index e1a399b3ca..3385bed333 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -710,6 +710,14 @@ gaih_inet (const char *name, const struct gaih_service *service, struct gaih_addrtuple *addrfree = addrmem; for (int i = 0; i < air->naddrs; ++i) { + if (!((air->family[i] == AF_INET + && req->ai_family == AF_INET6 + && (req->ai_flags & AI_V4MAPPED) != 0) + || req->ai_family == AF_UNSPEC + || air->family[i] == req->ai_family)) + /* Skip over non-matching result. */ + continue; + socklen_t size = (air->family[i] == AF_INET ? INADDRSZ : IN6ADDRSZ); if (*pat == NULL) |