summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritojun <itojun@openbsd.org>1999-12-11 08:32:20 +0000
committeritojun <itojun@openbsd.org>1999-12-11 08:32:20 +0000
commit04cda9706a43f5d37ea10cf45c93873b22681569 (patch)
tree3fffb8c7fb929de82111851b468cd07127f3d3d4
parentadd inet6_option_* and inet6_rthdr_*. (diff)
downloadwireguard-openbsd-04cda9706a43f5d37ea10cf45c93873b22681569.tar.xz
wireguard-openbsd-04cda9706a43f5d37ea10cf45c93873b22681569.zip
fix gethostbyname2(foo, AF_INET6).
on /etc/hosts lookup, file static variable "hosts" was damaged and prevented lookup of IPv6 hostnames.
-rw-r--r--lib/libc/net/gethostnamadr.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index f8f2ccd2d09..64be28a3512 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -52,7 +52,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.37 1999/09/03 18:12:31 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.38 1999/12/11 08:32:20 itojun Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -843,6 +843,11 @@ _gethtent()
} else {
goto again;
}
+ /* if this is not something we're looking for, skip it. */
+ if (host.h_addrtype != af)
+ goto again;
+ if (host.h_length != len)
+ goto again;
h_addr_ptrs[0] = (char *)host_addr;
h_addr_ptrs[1] = NULL;
host.h_addr_list = h_addr_ptrs;
@@ -920,6 +925,9 @@ _gethtbyaddr(addr, len, af)
{
register struct hostent *p;
+ host.h_length = len;
+ host.h_addrtype = af;
+
_sethtent(0);
while ((p = _gethtent()))
if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len))