summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Korsgaard <peter@korsgaard.com>2016-03-09 22:49:07 +0100
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-03-10 21:50:25 +0100
commit3c1457161e5206c2d576ab25d350a139511c096d (patch)
treec426e57ce8e8ed7c073802bc0774ad9eb8cde17a
parent8c85b44f6ab42561207365f19b9d1fd69d960771 (diff)
getaddrinfo: correct AI_V4MAPPED handling
As recently reported on the Buildroot list: http://lists.busybox.net/pipermail/buildroot/2016-March/155325.html DNS lookups with Node.js currently fails on uClibc-ng. The reason for this is the way AI_V4MAPPED is handled. According to POSIX, AI_V4MAPPED should be ignored unless ai_family is AF_INET6: http://pubs.opengroup.org/onlinepubs/9699919799/functions/freeaddrinfo.html If the AI_V4MAPPED flag is specified along with an ai_family of AF_INET6, then getaddrinfo() shall return IPv4-mapped IPv6 addresses on finding no matching IPv6 addresses (ai_addrlen shall be 16). The AI_V4MAPPED flag shall be ignored unless ai_family equals AF_INET6. uClibc-ng was also handling AI_V4MAPPED for AF_UNSPEC, fix that. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
-rw-r--r--libc/inet/getaddrinfo.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index 090d7e96e..7ae32be39 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -404,8 +404,7 @@ gaih_inet(const char *name, const struct gaih_service *service,
struct gaih_servtuple *st;
struct gaih_addrtuple *at;
int rc;
- int v4mapped = (req->ai_family == PF_UNSPEC || req->ai_family == PF_INET6)
- && (req->ai_flags & AI_V4MAPPED);
+ int v4mapped = req->ai_family == PF_INET6 && (req->ai_flags & AI_V4MAPPED);
unsigned seen = 0;
if (req->ai_flags & AI_ADDRCONFIG) {
/* "seen" is only used when AI_ADDRCONFIG is specified.