From 9c42c64d305549cc74dd10739d1fc5de813abe31 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 27 May 2000 08:09:40 +0000 Subject: (gaih_inet): If req->ai_family == AF_UNSPEC don't allow the IPv6 lookup to return mapped IPv4 addresses. --- sysdeps/posix/getaddrinfo.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sysdeps/posix') diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 59e2cec..45d1da2 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include #include @@ -430,11 +431,22 @@ gaih_inet (const char *name, const struct gaih_service *service, struct gaih_addrtuple **pat = &at; int no_data = 0; int no_inet6_data; + int old_res_options = _res.options; + + /* If we are looking for both IPv4 and IPv6 address we don't + want the lookup functions to automatically promote IPv4 + addresses to IPv6 addresses. Currently this is decided + by setting the RES_USE_INET6 bit in _res.options. */ + if (req->ai_family == AF_UNSPEC) + _res.options &= ~RES_USE_INET6; if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6) gethosts (AF_INET6, struct in6_addr); no_inet6_data = no_data; + if (req->ai_family == AF_UNSPEC) + _res.options = old_res_options; + if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET) gethosts (AF_INET, struct in_addr); -- cgit v1.1