about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2014-06-01 16:48:15 -0300
committerAlexandre Oliva <aoliva@redhat.com>2014-11-07 07:18:53 -0200
commitbc3ac8b1779e8b180762841048601b90f469d6e5 (patch)
tree1ef4527bbedd1f3321a84096134bced67c9d8402 /sysdeps
parent7875573cbe52eabe78f1cab91c8a046d0bd5ed5a (diff)
downloadglibc-bc3ac8b1779e8b180762841048601b90f469d6e5.tar.gz
glibc-bc3ac8b1779e8b180762841048601b90f469d6e5.tar.xz
glibc-bc3ac8b1779e8b180762841048601b90f469d6e5.zip
for ChangeLog
	PR network/9981
	* sysdeps/posix/getaddrinfo.c (getaddrinfo): Do not sort
	AI_PASSIVE addresses.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/posix/getaddrinfo.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 3cbd0334dd..3121d3bb65 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -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);