Blame SOURCES/glibc-rh714823.patch

b9ba6d
2011-06-28  Andreas Schwab  <schwab@redhat.com>
b9ba6d
b9ba6d
	* sysdeps/posix/getaddrinfo.c (gaih_inet): Don't use gethostbyaddr
b9ba6d
	to determine canonical name.
b9ba6d
b9ba6d
2011-06-22  Andreas Schwab  <schwab@redhat.com>
b9ba6d
b9ba6d
	* sysdeps/posix/getaddrinfo.c (gaih_inet): Fix last change.
b9ba6d
b9ba6d
2011-06-21  Ulrich Drepper  <drepper@gmail.com>
b9ba6d
b9ba6d
	[BZ #12885]
b9ba6d
	* sysdeps/posix/getaddrinfo.c (gaih_inet): When looking up only IPv6
b9ba6d
	addresses using gethostbyname4_r ignore IPv4 addresses.
b9ba6d
b9ba6d
Index: glibc-2.12-2-gc4ccff1/sysdeps/posix/getaddrinfo.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/posix/getaddrinfo.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/sysdeps/posix/getaddrinfo.c
b9ba6d
@@ -512,10 +512,11 @@ gaih_inet (const char *name, const struc
b9ba6d
 
b9ba6d
 	  /* If we do not have to look for IPv4 and IPv6 together, use
b9ba6d
 	     the simple, old functions.  */
b9ba6d
-	  if (req->ai_family == AF_INET
b9ba6d
-	      || (req->ai_family == AF_INET6
b9ba6d
-		  && ((req->ai_flags & AI_V4MAPPED) == 0
b9ba6d
-		      || (req->ai_flags & AI_ALL) == 0)))
b9ba6d
+	  if ((req->ai_family == AF_INET
b9ba6d
+	       || (req->ai_family == AF_INET6
b9ba6d
+		   && ((req->ai_flags & AI_V4MAPPED) == 0
b9ba6d
+		       || (req->ai_flags & AI_ALL) == 0)))
b9ba6d
+	      && (req->ai_flags & AI_CANONNAME) == 0)
b9ba6d
 	    {
b9ba6d
 	      int family = req->ai_family;
b9ba6d
 	      size_t tmpbuflen = 512;
b9ba6d
@@ -731,16 +732,44 @@ gaih_inet (const char *name, const struc
b9ba6d
 					      tmpbuflen, 2 * tmpbuflen);
b9ba6d
 		    }
b9ba6d
 
b9ba6d
-		  no_inet6_data = no_data;
b9ba6d
-
b9ba6d
 		  if (status == NSS_STATUS_SUCCESS)
b9ba6d
 		    {
b9ba6d
+		      assert (!no_data);
b9ba6d
+		      no_data = 1;
b9ba6d
+
b9ba6d
 		      if ((req->ai_flags & AI_CANONNAME) != 0 && canon == NULL)
b9ba6d
 			canon = (*pat)->name;
b9ba6d
 
b9ba6d
 		      while (*pat != NULL)
b9ba6d
-			pat = &((*pat)->next);
b9ba6d
+			{
b9ba6d
+			  if ((*pat)->family == AF_INET
b9ba6d
+			      && req->ai_family == AF_INET6
b9ba6d
+			      && (req->ai_flags & AI_V4MAPPED) != 0)
b9ba6d
+			    {
b9ba6d
+			      uint32_t *pataddr = (*pat)->addr;
b9ba6d
+			      (*pat)->family = AF_INET6;
b9ba6d
+			      pataddr[3] = pataddr[0];
b9ba6d
+			      pataddr[2] = htonl (0xffff);
b9ba6d
+			      pataddr[1] = 0;
b9ba6d
+			      pataddr[0] = 0;
b9ba6d
+			      pat = &((*pat)->next);
b9ba6d
+			      no_data = 0;
b9ba6d
+			    }
b9ba6d
+			  else if (req->ai_family == AF_UNSPEC
b9ba6d
+				   || (*pat)->family == req->ai_family)
b9ba6d
+			    {
b9ba6d
+			      pat = &((*pat)->next);
b9ba6d
+
b9ba6d
+			      no_data = 0;
b9ba6d
+			      if (req->ai_family == AF_INET6)
b9ba6d
+				got_ipv6 = true;
b9ba6d
+			    }
b9ba6d
+			  else
b9ba6d
+			    *pat = ((*pat)->next);
b9ba6d
+			}
b9ba6d
 		    }
b9ba6d
+
b9ba6d
+		  no_inet6_data = no_data;
b9ba6d
 		}
b9ba6d
 	      else
b9ba6d
 		{
b9ba6d
@@ -905,39 +934,9 @@ gaih_inet (const char *name, const struc
b9ba6d
 	  {
b9ba6d
 	    if (canon == NULL)
b9ba6d
 	      {
b9ba6d
-		struct hostent *h = NULL;
b9ba6d
-		int herrno;
b9ba6d
-		struct hostent th;
b9ba6d
-		size_t tmpbuflen = 512;
b9ba6d
-		char *tmpbuf = NULL;
b9ba6d
-
b9ba6d
-		do
b9ba6d
-		  {
b9ba6d
-		    tmpbuf = extend_alloca (tmpbuf, tmpbuflen, tmpbuflen * 2);
b9ba6d
-		    rc = __gethostbyaddr_r (at2->addr,
b9ba6d
-					    ((at2->family == AF_INET6)
b9ba6d
-					     ? sizeof (struct in6_addr)
b9ba6d
-					     : sizeof (struct in_addr)),
b9ba6d
-					    at2->family, &th, tmpbuf,
b9ba6d
-					    tmpbuflen, &h, &herrno);
b9ba6d
-		  }
b9ba6d
-		while (rc == ERANGE && herrno == NETDB_INTERNAL);
b9ba6d
-
b9ba6d
-		if (rc != 0 && herrno == NETDB_INTERNAL)
b9ba6d
-		  {
b9ba6d
-		    __set_h_errno (herrno);
b9ba6d
-		    return -EAI_SYSTEM;
b9ba6d
-		  }
b9ba6d
-
b9ba6d
-		if (h != NULL)
b9ba6d
-		  canon = h->h_name;
b9ba6d
-		else
b9ba6d
-		  {
b9ba6d
-		    assert (orig_name != NULL);
b9ba6d
-		    /* If the canonical name cannot be determined, use
b9ba6d
-		       the passed in string.  */
b9ba6d
-		    canon = orig_name;
b9ba6d
-		  }
b9ba6d
+		/* If the canonical name cannot be determined, use
b9ba6d
+		   the passed in string.  */
b9ba6d
+		canon = orig_name;
b9ba6d
 	      }
b9ba6d
 
b9ba6d
 #ifdef HAVE_LIBIDN