Fix Coverity bug 603941: Negative array index read

Signed-off-by: Philippe Saint-Pierre <stpere@gmail.com>
This commit is contained in:
Puck Meerburg 2013-12-23 23:32:52 +00:00 committed by Philippe Saint-Pierre
parent 37b6c4337c
commit d32cb23734

View File

@ -135,8 +135,8 @@ 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) {
rdata = &buf[n];
n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata,
NS_OPT_NSID, 0, NULL);
}