]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
for ChangeLog
authorAlexandre Oliva <aoliva@redhat.com>
Sun, 1 Jun 2014 19:48:15 +0000 (16:48 -0300)
committerAlexandre Oliva <aoliva@redhat.com>
Fri, 7 Nov 2014 09:18:53 +0000 (07:18 -0200)
PR network/9981
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Do not sort
AI_PASSIVE addresses.

sysdeps/posix/getaddrinfo.c

index 3cbd0334dda8dc68129fc20df80785a0117a5184..3121d3bb65263e0d38098aec9b899a57e1e3ce01 100644 (file)
@@ -2435,7 +2435,11 @@ getaddrinfo (const char *name, const char *service,
       return EAI_FAMILY;
     }
 
-  if (naddrs > 1)
+  /* We don't want to sort the localhost addresses used for passive
+     binding; if the caller asked for both address types, we want to
+     return IPv6+IPv4 before IPv4, because if we bind to IPv4 first,
+     the IPv6 bind will fail.  */
+  if (naddrs > 1 && (name || (hints->ai_flags & AI_PASSIVE) == 0))
     {
       /* Read the config file.  */
       __libc_once_define (static, once);