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.
This commit is contained in:
Guy Harris 2014-07-08 03:23:09 -07:00
parent 1363a442cc
commit b6a3595a55

View File

@ -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) {