diff options
author | nectar <nectar@FreeBSD.org> | 2002-09-15 16:51:09 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2002-09-15 16:51:09 +0000 |
commit | b44001f0c35c71357de671925af59585fe44a345 (patch) | |
tree | b148cf252878680c37bb7a53070e4d454eed0300 /lib/libc/net/gethostbydns.c | |
parent | 486bc9dab8aab95468a5910f1ad064ed33582577 (diff) | |
download | FreeBSD-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/gethostbydns.c')
-rw-r--r-- | lib/libc/net/gethostbydns.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c index 1044727..0effbe4 100644 --- a/lib/libc/net/gethostbydns.c +++ b/lib/libc/net/gethostbydns.c @@ -587,9 +587,13 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap) break; } - if ((n = res_search(name, C_IN, type, buf.buf, sizeof(buf))) < 0) { + n = res_search(name, C_IN, type, buf.buf, sizeof(buf.buf)); + if (n < 0) { dprintf("res_search failed (%d)\n", n); - return NS_UNAVAIL; + return (NULL); + } else if (n > sizeof(buf.buf)) { + dprintf("static buffer is too small (%d)\n", n); + return (NULL); } *(struct hostent **)rval = gethostanswer(&buf, n, name, type); return (*(struct hostent **)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND; |