diff options
author | ume <ume@FreeBSD.org> | 2005-04-30 20:07:01 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2005-04-30 20:07:01 +0000 |
commit | eff8f31f8b0bffb36780a423c2307f514ac22269 (patch) | |
tree | 0fe67750816f865bc9fcf51ab90e59cc37f4abdf /lib/libc/net/gethostbyht.c | |
parent | c8fa8099674d921d50dae72e3a58ef66ac9c7fbc (diff) | |
download | FreeBSD-src-eff8f31f8b0bffb36780a423c2307f514ac22269.zip FreeBSD-src-eff8f31f8b0bffb36780a423c2307f514ac22269.tar.gz |
oops, gethostbyaddr(3) must return h_addr as an IPv4-mapped
IPv6 address when RES_USE_INET6 was set, according to RFC 2133
section 6.2.
Diffstat (limited to 'lib/libc/net/gethostbyht.c')
-rw-r--r-- | lib/libc/net/gethostbyht.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c index 452a6da..d1ef23b 100644 --- a/lib/libc/net/gethostbyht.c +++ b/lib/libc/net/gethostbyht.c @@ -246,8 +246,15 @@ _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap) sethostent_r(0, hed); while ((error = gethostent_p(he, hed, 0)) == 0) - if (he->h_addrtype == af && !bcmp(he->h_addr, addr, len)) + if (he->h_addrtype == af && !bcmp(he->h_addr, addr, len)) { + if (he->h_addrtype == AF_INET && + _res.options & RES_USE_INET6) { + _map_v4v6_address(he->h_addr, he->h_addr); + he->h_length = IN6ADDRSZ; + he->h_addrtype = AF_INET6; + } break; + } endhostent_r(hed); return (error == 0) ? NS_SUCCESS : NS_NOTFOUND; |