OSDN Git Service

resolv: fix gethostbyname2_r to match gethostbyname_r, fixing bugs with AAAA lookups
authorWaldemar Brodkorb <wbx@uclibc-ng.org>
Tue, 22 Dec 2015 09:47:56 +0000 (10:47 +0100)
committerWaldemar Brodkorb <wbx@uclibc-ng.org>
Sat, 26 Dec 2015 19:23:50 +0000 (20:23 +0100)
commit990f2ce7da5ee67599d6d8a12b681713776275e0
treee7b0cb8aa56f499b8c3c0e4e0cb9eecb1907bf31
parent5659e2a1c763a51957c3e9bd13737534a1d894c6
resolv: fix gethostbyname2_r to match gethostbyname_r, fixing bugs with AAAA lookups

The latter half of gethostbyname2_r (doing AAAA queries) is rather dramatically different
from the corresponding portion of gethostbyname_r (doing A queries). This leads to problems
like calls to getaddrinfo only returning one IPv6 address, even when multiple exist.

Seems to be entirely a case of divergent evolution -- a half-decade of fixes for the IPv4
code but no love for IPv6. Until now. ;)

DNS behaviour for IPv6 is really no different than for IPv4 -- beyond the difference in
address sizes, there's no need for the functions to be so different.

Consequently, this patch really is almost just a cut-and-paste of gethostbyname_r, with
the appropriate substitutions of in6_addr, AF_INET6, etc; while holding on to the few
extra bits that actually belong in there (eg #ifdef __UCLIBC_HAS_IPV6__).

Signed-off-by: Wes Campaigne <westacular@gmail.com>
libc/inet/resolv.c