about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2014-05-07 11:47:20 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-10-02 09:21:25 +0200
commitb0f0937975ef3c0f4c514fe29137549c27be0cf0 (patch)
tree9f0c3c82792ee35516e82180e39f3a3d4eb5248d
parentb59b0c6c3f8a9434fe5d4ee1a954091ad29669c1 (diff)
downloadglibc-b0f0937975ef3c0f4c514fe29137549c27be0cf0.tar.gz
glibc-b0f0937975ef3c0f4c514fe29137549c27be0cf0.tar.xz
glibc-b0f0937975ef3c0f4c514fe29137549c27be0cf0.zip
Fix parsing of getai result from nscd for IPv6-only request
(cherry picked from commit 8dc9751764eb1bedf06d19695524b31a16773413)
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getaddrinfo.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 51573d0c2d..6aff2a266b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-02  Andreas Schwab  <schwab@suse.de>
+
+	* sysdeps/posix/getaddrinfo.c (gaih_inet): Advance address pointer
+	when skipping over non-matching result from nscd.
+
 2015-09-11  Alan Modra  <amodra@gmail.com>
 
 	[BZ #17153]
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index b3cc1246cb..d2283bcd4a 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -710,16 +710,20 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		  struct gaih_addrtuple *addrfree = addrmem;
 		  for (int i = 0; i < air->naddrs; ++i)
 		    {
+		      socklen_t size = (air->family[i] == AF_INET
+					? INADDRSZ : IN6ADDRSZ);
+
 		      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;
+			{
+			  /* Skip over non-matching result.  */
+			  addrs += size;
+			  continue;
+			}
 
-		      socklen_t size = (air->family[i] == AF_INET
-					? INADDRSZ : IN6ADDRSZ);
 		      if (*pat == NULL)
 			{
 			  *pat = addrfree++;