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.
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);
*/
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) {