summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/getaddrinfo.c
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2002-09-15 16:51:09 +0000
committernectar <nectar@FreeBSD.org>2002-09-15 16:51:09 +0000
commitb44001f0c35c71357de671925af59585fe44a345 (patch)
treeb148cf252878680c37bb7a53070e4d454eed0300 /lib/libc/net/getaddrinfo.c
parent486bc9dab8aab95468a5910f1ad064ed33582577 (diff)
downloadFreeBSD-src-b44001f0c35c71357de671925af59585fe44a345.zip
FreeBSD-src-b44001f0c35c71357de671925af59585fe44a345.tar.gz
Check for truncation in calls to res_send/res_query/res_search.
Fail when it is detected.
Diffstat (limited to 'lib/libc/net/getaddrinfo.c')
-rw-r--r--lib/libc/net/getaddrinfo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 0f724f9..ccd5d6e 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1829,7 +1829,9 @@ res_queryN(name, target)
}
#endif
- if (n < 0 || hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
+ if (n < 0 || n > anslen)
+ hp->rcode = FORMERR; /* XXX not very informative */
+ if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
rcode = hp->rcode; /* record most recent error */
#ifdef DEBUG
if (_res.options & RES_DEBUG)
OpenPOWER on IntegriCloud