From f31b0f0048dca1800699df5a79d7f3c9067a6a03 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Sat, 28 Sep 1996 13:26:34 +0000 Subject: bzzzt --- src/lib/libc/net/gethostnamadr.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c index c9220e1cf6..6d5124d308 100644 --- a/src/lib/libc/net/gethostnamadr.c +++ b/src/lib/libc/net/gethostnamadr.c @@ -52,7 +52,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.11 1996/09/27 18:50:04 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.12 1996/09/28 13:26:34 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -171,7 +171,6 @@ getanswer(answer, anslen, iquery) } cp += n + QFIXEDSZ; host.h_name = bp; - host.h_length = INADDRSZ; n = strlen(bp); if (n >= MAXHOSTNAMELEN) host.h_name[MAXHOSTNAMELEN-1] = '\0'; @@ -241,17 +240,21 @@ getanswer(answer, anslen, iquery) continue; } - if (n != host.h_length) { - cp += n; - continue; - } - if (class != getclass) { - cp += n; - continue; - } - if (!haveanswer) { + if (haveanswer) { + if (n != host.h_length) { + cp += n; + continue; + } + if (class != getclass) { + cp += n; + continue; + } + } else { + host.h_length = n; getclass = class; host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; + if (host.h_addrtype == AF_INET) + host.h_length = INADDRSZ; if (!iquery) { host.h_name = bp; bp += strlen(bp) + 1; -- cgit v1.2.3-55-g6feb