29e444
2009-04-26  Aurelien Jarno  <aurelien@aurel32.net>
29e444
29e444
	* sysdeps/posix/getaddrinfo.c (rfc3484_sort): don't assign native
29e444
	result if the result has no associated interface.
29e444
29e444
---
29e444
 sysdeps/posix/getaddrinfo.c |    4 ++--
29e444
 1 file changed, 2 insertions(+), 2 deletions(-)
29e444
12745e
--- glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
12745e
+++ glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
29e444
@@ -1456,13 +1456,13 @@
29e444
 
29e444
 	      /* Fill in the results in all the records.  */
29e444
 	      for (int i = 0; i < src->nresults; ++i)
29e444
-		if (src->results[i].index == a1_index)
29e444
+		if (a1_index != -1 && src->results[i].index == a1_index)
29e444
 		  {
29e444
 		    assert (src->results[i].native == -1
29e444
 			    || src->results[i].native == a1_native);
29e444
 		    src->results[i].native = a1_native;
29e444
 		  }
29e444
-		else if (src->results[i].index == a2_index)
29e444
+		else if (a2_index != -1 && src->results[i].index == a2_index)
29e444
 		  {
29e444
 		    assert (src->results[i].native == -1
29e444
 			    || src->results[i].native == a2_native);
29e444
29e444
2009-03-15  Aurelien Jarno  <aurelien@aurel32.net>
29e444
29e444
	* sysdeps/posix/getaddrinfo.c (getaddrinfo): correctly detect 
29e444
	interface for all 127.X.Y.Z addresses.
29e444
29e444
---
29e444
 sysdeps/posix/getaddrinfo.c |    9 ++++++++-
29e444
 1 file changed, 8 insertions(+), 1 deletion(-)
29e444
12745e
--- glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
12745e
+++ glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
29e444
@@ -2265,7 +2265,14 @@
29e444
 			  tmp.addr[0] = 0;
29e444
 			  tmp.addr[1] = 0;
29e444
 			  tmp.addr[2] = htonl (0xffff);
29e444
-			  tmp.addr[3] = sinp->sin_addr.s_addr;
29e444
+			  /* Special case for lo interface, the source address
29e444
+			     being possibly different than the interface 
29e444
+			     address. */
29e444
+			  if ((ntohl(sinp->sin_addr.s_addr) & 0xff000000)
29e444
+			      == 0x7f000000)
29e444
+			    tmp.addr[3] = htonl(0x7f000001);
29e444
+			  else
29e444
+			    tmp.addr[3] = sinp->sin_addr.s_addr;
29e444
 			}
29e444
 		      else
29e444
 			{