aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/gethostbydns.c1
-rw-r--r--lib/libc/net/getnetbydns.c4
-rw-r--r--lib/libc/net/name6.c4
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index a5a3e7bb30fe..52ac91a041be 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -389,6 +389,7 @@ gethostanswer(answer, anslen, qname, qtype)
buflen -= nn;
}
+ buflen -= sizeof(align) - ((u_long)bp % sizeof(align));
bp += sizeof(align) - ((u_long)bp % sizeof(align));
if (bp + n >= &hostbuf[sizeof hostbuf]) {
diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c
index 087aa5f6b9bf..e1a11d2e5d3a 100644
--- a/lib/libc/net/getnetbydns.c
+++ b/lib/libc/net/getnetbydns.c
@@ -173,7 +173,9 @@ static char *net_aliases[MAXALIASES], netbuf[PACKETSZ];
}
cp += n;
*ap++ = bp;
- bp += strlen(bp) + 1;
+ n = strlen(bp) + 1;
+ bp += n;
+ buflen -= n;
net_entry.n_addrtype =
(class == C_IN) ? AF_INET : AF_UNSPEC;
haveanswer++;
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c
index 8edcb1bee858..401786811b50 100644
--- a/lib/libc/net/name6.c
+++ b/lib/libc/net/name6.c
@@ -1024,7 +1024,7 @@ getanswer(answer, anslen, qname, qtype, template, errp)
register const u_char *cp;
register int n;
const u_char *eom, *erdata;
- char *bp, **ap, **hap;
+ char *bp, **ap, **hap, *obp;
int type, class, buflen, ancount, qdcount;
int haveanswer, had_error;
char tbuf[MAXDNAME];
@@ -1238,7 +1238,9 @@ getanswer(answer, anslen, qname, qtype, template, errp)
bp += nn;
buflen -= nn;
}
+ obp = bp; /* ALIGN rounds up */
bp = (char *)ALIGN(bp);
+ buflen -= (bp - obp);
DNS_FATAL(bp + n < &hostbuf[sizeof hostbuf]);
DNS_ASSERT(hap < &h_addr_ptrs[MAXADDRS-1]);