summaryrefslogtreecommitdiff
path: root/lib/libc/net
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>1999-12-11 08:32:21 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>1999-12-11 08:32:21 +0000
commit00dfa6dd9d0c8d9b7025ff4a6286b58ceac9d337 (patch)
treef8dd8f35fc6b0645a0c0bda4f324e4352ced16f4 /lib/libc/net
parent819a282f8ad2a473c702d4d0cba73bc4f8fe19ad (diff)
fix gethostbyname2(foo, AF_INET6).
on /etc/hosts lookup, file static variable "hosts" was damaged and prevented lookup of IPv6 hostnames.
Diffstat (limited to 'lib/libc/net')
-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))