svn commit: r299879 - head/lib/libc/resolv

Don Lewis truckman at FreeBSD.org
Mon May 16 01:30:34 UTC 2016


Author: truckman
Date: Mon May 16 01:30:32 2016
New Revision: 299879
URL: https://svnweb.freebsd.org/changeset/base/299879

Log:
  Likely a false positive ... but make sure that -1 can't be used as an
  array index by splitting up a test.
  
  Reported by:	Coverity
  CID:		603941
  MFC after:	1 week

Modified:
  head/lib/libc/resolv/res_query.c

Modified: head/lib/libc/resolv/res_query.c
==============================================================================
--- head/lib/libc/resolv/res_query.c	Mon May 16 01:12:56 2016	(r299878)
+++ head/lib/libc/resolv/res_query.c	Mon May 16 01:30:32 2016	(r299879)
@@ -135,10 +135,12 @@ again:
 	if (n > 0 && (statp->_flags & RES_F_EDNS0ERR) == 0 &&
 	    (statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC|RES_NSID))) {
 		n = res_nopt(statp, n, buf, sizeof(buf), anslen);
-		rdata = &buf[n];
-		if (n > 0 && (statp->options & RES_NSID) != 0U) {
-			n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata,
-					   NS_OPT_NSID, 0, NULL);
+		if (n > 0) {
+			rdata = &buf[n];
+			if ((statp->options & RES_NSID) != 0U) {
+				n = res_nopt_rdata(statp, n, buf, sizeof(buf),
+						   rdata, NS_OPT_NSID, 0, NULL);
+			}
 		}
 	}
 #endif


More information about the svn-src-all mailing list