diff mbox

Fix parsing of getai result from nscd

Message ID mvmppjpzymr.fsf@hawking.suse.de
State New
Headers show

Commit Message

Andreas Schwab May 7, 2014, 10:11 a.m. UTC
With nscd running, getaddrinfo misparses the getai result from nscd if
an IPv6-only result was requested.

Andreas.

	* sysdeps/posix/getaddrinfo.c (gaih_inet): Advance address pointer
	when skipping over non-matching result from nscd.
---
 sysdeps/posix/getaddrinfo.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Ondřej Bílka May 7, 2014, 11:31 a.m. UTC | #1
On Wed, May 07, 2014 at 12:11:56PM +0200, Andreas Schwab wrote:
> With nscd running, getaddrinfo misparses the getai result from nscd if
> an IPv6-only result was requested.
> 
> Andreas.
> 
ok for me.
diff mbox

Patch

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 3385bed..6258330 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++;