diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index e3986d9519..a2972b1bca 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -604,8 +604,12 @@ gaih_inet (const char *name, const struct gaih_service *service, { if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6) at->family = AF_INET6; - else if (IN6_IS_ADDR_V4MAPPED (at->addr)) - *(uint32_t *) at->addr = ((uint32_t *) at->addr)[3]; + else if (req->ai_family == AF_INET + && IN6_IS_ADDR_V4MAPPED (at->addr)) + { + *(uint32_t *) at->addr = ((uint32_t *) at->addr)[3]; + at->family = AF_INET; + } else return -EAI_ADDRFAMILY; @@ -662,7 +666,7 @@ gaih_inet (const char *name, const struct gaih_service *service, no_more = __nss_database_lookup ("hosts", NULL, "dns [!UNAVAIL=return] files", &nip); - if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1) + if (__res_maybe_init (&_res, 0) == -1) no_more = 1; old_res_options = _res.options; _res.options &= ~RES_USE_INET6; |