From: Guy Harris Date: Tue, 8 Jul 2014 10:23:09 +0000 (-0700) Subject: Squelch a Coverity warning. X-Git-Tag: tcpdump-4.6.1~7 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/71e7e0f594b13176f0b65549b7711fd55ceb0828 Squelch a Coverity warning. If you pass in a value of oidlen and oidsize such that we can't store *anything* into OID, this would be a problem; that *shouldn't* ever happen, but this makes the code a bit more obviously correct. --- diff --git a/print-snmp.c b/print-snmp.c index 40d559da..f38fff70 100644 --- a/print-snmp.c +++ b/print-snmp.c @@ -898,6 +898,7 @@ smi_decode_oid(netdissect_options *ndo, u_char *p = (u_char *)elem->data.raw; uint32_t asnlen = elem->asnlen; int o = 0, first = -1, i = asnlen; + unsigned int firstval; for (*oidlen = 0; ndo->ndo_sflag && i-- > 0; p++) { ND_TCHECK(*p); @@ -911,11 +912,12 @@ smi_decode_oid(netdissect_options *ndo, */ if (first < 0) { first = 0; + firstval = o / OIDMUX; + if (firstval > 2) firstval = 2; if (*oidlen < oidsize) { - oid[*oidlen] = o / OIDMUX; - if (oid[*oidlen] > 2) oid[*oidlen] = 2; + oid[*oidlen] = firstval; } - o -= oid[*oidlen] * OIDMUX; + o -= firstval * OIDMUX; if (*oidlen < oidsize) (*oidlen)++; } if (*oidlen < oidsize) {