From 98a47ed075e14b6f583a8f172aa18095911fa89c Mon Sep 17 00:00:00 2001 From: lukem Date: Tue, 23 Nov 2004 03:42:13 +0000 Subject: [PATCH] Fix gethostent(3) (which was reenabled in rev 1.63) so that it actually works by allowing _gethtent() to treat host.h_addrtype==0 && host.h_length==0 as "any address family" when parsing. --- lib/libc/net/gethnamaddr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libc/net/gethnamaddr.c b/lib/libc/net/gethnamaddr.c index b719fff46754..1178908a5685 100644 --- a/lib/libc/net/gethnamaddr.c +++ b/lib/libc/net/gethnamaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: gethnamaddr.c,v 1.63 2004/08/17 02:29:56 ginsbach Exp $ */ +/* $NetBSD: gethnamaddr.c,v 1.64 2004/11/23 03:42:13 lukem Exp $ */ /* * ++Copyright++ 1985, 1988, 1993 @@ -57,7 +57,7 @@ static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp "; #else -__RCSID("$NetBSD: gethnamaddr.c,v 1.63 2004/08/17 02:29:56 ginsbach Exp $"); +__RCSID("$NetBSD: gethnamaddr.c,v 1.64 2004/11/23 03:42:13 lukem Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -783,9 +783,9 @@ _gethtent(void) goto again; } /* if this is not something we're looking for, skip it. */ - if (host.h_addrtype != af) + if (host.h_addrtype != 0 && host.h_addrtype != af) goto again; - if (host.h_length != len) + if (host.h_length != 0 && host.h_length != len) goto again; h_addr_ptrs[0] = (char *)(void *)host_addr; h_addr_ptrs[1] = NULL; @@ -1067,6 +1067,8 @@ addrsort(char **ap, int num, res_state res) struct hostent * gethostent(void) { + host.h_addrtype = 0; + host.h_length = 0; return _gethtent(); }