From b44a616ea5c66f88ef4bccbb7583afc03acb4c33 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Fri, 27 Sep 1996 18:50:05 +0000 Subject: more INADDRSZ pedantry --- lib/libc/net/gethostnamadr.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index 3830e52cc64..c9220e1cf67 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.10 1996/09/27 18:37:11 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.11 1996/09/27 18:50:04 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -171,6 +171,7 @@ 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'; @@ -240,21 +241,17 @@ getanswer(answer, anslen, iquery) continue; } - if (haveanswer) { - if (n != host.h_length) { - cp += n; - continue; - } - if (class != getclass) { - cp += n; - continue; - } - } else { - host.h_length = n; + if (n != host.h_length) { + cp += n; + continue; + } + if (class != getclass) { + cp += n; + continue; + } + if (!haveanswer) { 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