diff options
author | ume <ume@FreeBSD.org> | 2005-04-30 17:01:18 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2005-04-30 17:01:18 +0000 |
commit | 1e5d47dc8ca25db110b85fa16f9caf196d07a62e (patch) | |
tree | a21423158c4806ec07585cd9ac9143f2249353c9 /lib/libc/net/gethostbyht.c | |
parent | fe9d4ac270a8516807825d5d7af8f70b777e693e (diff) | |
download | FreeBSD-src-1e5d47dc8ca25db110b85fa16f9caf196d07a62e.zip FreeBSD-src-1e5d47dc8ca25db110b85fa16f9caf196d07a62e.tar.gz |
_ht_gethostbyname didn't handle RES_USE_INET6 correctly.
Diffstat (limited to 'lib/libc/net/gethostbyht.c')
-rw-r--r-- | lib/libc/net/gethostbyht.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c index 7024ef2..20cc97e 100644 --- a/lib/libc/net/gethostbyht.c +++ b/lib/libc/net/gethostbyht.c @@ -90,8 +90,8 @@ _endhosthtent(struct hostent_data *hed) } } -int -gethostent_r(struct hostent *he, struct hostent_data *hed) +static int +gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped) { char *p, *bp, *ep; char *cp, **q; @@ -119,7 +119,7 @@ gethostent_r(struct hostent *he, struct hostent_data *hed) af = AF_INET6; len = IN6ADDRSZ; } else if (inet_pton(AF_INET, p, hed->host_addr) > 0) { - if (_res.options & RES_USE_INET6) { + if (mapped) { _map_v4v6_address((char *)hed->host_addr, (char *)hed->host_addr); af = AF_INET6; @@ -174,6 +174,12 @@ gethostent_r(struct hostent *he, struct hostent_data *hed) return 0; } +int +gethostent_r(struct hostent *he, struct hostent_data *hed) +{ + return gethostent_p(he, hed, _res.options & RES_USE_INET6); +} + struct hostent * gethostent(void) { @@ -187,7 +193,7 @@ gethostent(void) } int -_ht_gethostbyname(void *rval, void *cb_data, va_list ap) +_ht_gethostbyname(void *rval, void *cb_data, va_list ap) { const char *name; int af; @@ -202,9 +208,15 @@ _ht_gethostbyname(void *rval, void *cb_data, va_list ap) hed = va_arg(ap, struct hostent_data *); sethostent_r(0, hed); - while ((error = gethostent_r(he, hed)) == 0) { + while ((error = gethostent_p(he, hed, 0)) == 0) { if (he->h_addrtype != af) continue; + 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; + } if (strcasecmp(he->h_name, name) == 0) break; for (cp = he->h_aliases; *cp != 0; cp++) @@ -217,7 +229,7 @@ found: return (error == 0) ? NS_SUCCESS : NS_NOTFOUND; } -int +int _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap) { const char *addr; |