* sysdeps/posix/getaddrinfo.c (getaddrinfo): Only restrict search

to IPv4 or IPv6 if an interface has been found.
This commit is contained in:
Ulrich Drepper 2008-11-27 06:31:04 +00:00
parent ca4dc0fe64
commit be4607eba8
2 changed files with 3 additions and 9 deletions

View File

@ -1,7 +1,7 @@
2008-11-26 Ulrich Drepper <drepper@redhat.com> 2008-11-26 Ulrich Drepper <drepper@redhat.com>
* sysdeps/posix/getaddrinfo.c (getaddrinfo): If the system has * sysdeps/posix/getaddrinfo.c (getaddrinfo): Only restrict search
neither IPv4 nor IPv6 addresses defined, don't do anything. to IPv4 or IPv6 if an interface has been found.
2008-11-26 Roland McGrath <roland@redhat.com> 2008-11-26 Roland McGrath <roland@redhat.com>

View File

@ -2108,13 +2108,8 @@ getaddrinfo (const char *name, const char *service,
{ {
/* If we haven't seen both IPv4 and IPv6 interfaces we can /* If we haven't seen both IPv4 and IPv6 interfaces we can
narrow down the search. */ narrow down the search. */
if (! seen_ipv4 || ! seen_ipv6) if ((! seen_ipv4 || ! seen_ipv6) && (seen_ipv4 || seen_ipv6))
{ {
if (! seen_ipv4 && ! seen_ipv6)
/* Neither IPv4 nor IPv6 interfaces exist, nothing to
return. */
goto err_noname;
local_hints = *hints; local_hints = *hints;
local_hints.ai_family = seen_ipv4 ? PF_INET : PF_INET6; local_hints.ai_family = seen_ipv4 ? PF_INET : PF_INET6;
hints = &local_hints; hints = &local_hints;
@ -2124,7 +2119,6 @@ getaddrinfo (const char *name, const char *service,
|| (hints->ai_family == PF_INET6 && ! seen_ipv6)) || (hints->ai_family == PF_INET6 && ! seen_ipv6))
{ {
/* We cannot possibly return a valid answer. */ /* We cannot possibly return a valid answer. */
err_noname:
free (in6ai); free (in6ai);
return EAI_NONAME; return EAI_NONAME;
} }