getaddrinfo: correct AI_V4MAPPED handling
commit3c1457161e5206c2d576ab25d350a139511c096d
authorPeter Korsgaard <peter@korsgaard.com>
Wed, 9 Mar 2016 21:49:07 +0000 (9 22:49 +0100)
committerWaldemar Brodkorb <wbx@uclibc-ng.org>
Thu, 10 Mar 2016 20:50:25 +0000 (10 21:50 +0100)
treec426e57ce8e8ed7c073802bc0774ad9eb8cde17a
parent8c85b44f6ab42561207365f19b9d1fd69d960771
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>
libc/inet/getaddrinfo.c