From d13ee748a5bdd54ad164bf029b23c8f01d724390 Mon Sep 17 00:00:00 2001 From: truckman Date: Fri, 20 May 2016 07:18:33 +0000 Subject: [PATCH] MFC r299879, r299880 r299879 | truckman | 2016-05-15 18:30:32 -0700 (Sun, 15 May 2016) | 7 lines Likely a false positive ... but make sure that -1 can't be used as an array index by splitting up a test. r299880 | truckman | 2016-05-15 18:38:24 -0700 (Sun, 15 May 2016) | 8 lines Since rdata is only used as an argument to the immediately following call to res_nopt_rdata(), revert r299879 and fix CID 603941 by moving rdata = &buf[n]; inside the if block. Reported by: Coverity CID: 603941 git-svn-id: svn://svn.freebsd.org/base/stable/10@300286 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libc/resolv/res_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c index 5992edd8a..a6df3f26c 100644 --- a/lib/libc/resolv/res_query.c +++ b/lib/libc/resolv/res_query.c @@ -136,8 +136,8 @@ res_nquery(res_state statp, 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) { + rdata = &buf[n]; n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata, NS_OPT_NSID, 0, NULL); } -- 2.45.0