Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net Fix gethostent(3) (which was reenabled in rev 1...



details:   https://anonhg.NetBSD.org/src/rev/4a074f0095aa
branches:  trunk
changeset: 571414:4a074f0095aa
user:      lukem <lukem%NetBSD.org@localhost>
date:      Tue Nov 23 03:42:13 2004 +0000

description:
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.

diffstat:

 lib/libc/net/gethnamaddr.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 3ad0f8e48c68 -r 4a074f0095aa lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c        Tue Nov 23 03:11:33 2004 +0000
+++ b/lib/libc/net/gethnamaddr.c        Tue Nov 23 03:42:13 2004 +0000
@@ -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 @@
                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 @@
 struct hostent *
 gethostent(void)
 {
+       host.h_addrtype = 0;
+       host.h_length = 0;
        return _gethtent();
 }
 



Home | Main Index | Thread Index | Old Index