This fix some undefined behaviors at runtime.
The errors were like:
print-ether.c:241:11: runtime error: unsigned integer overflow:
1 - 2 cannot be represented in type 'unsigned int'
print-ether.c:242:11: runtime error: unsigned integer overflow:
1 - 2 cannot be represented in type 'unsigned int'
Moreover:
Fix indentation.
}
int ret = macsec_print(ndo, &p, &length, &caplen, &hdrlen,
- &src, &dst);
+ &src, &dst);
if (ret == 0) {
/* Payload is encrypted; print it as raw data. */
*/
length_type = GET_BE_U_2(p);
+ ND_LCHECK_U(caplen, 2);
length -= 2;
caplen -= 2;
p += 2;
ND_DEFAULTPRINT(p, caplen);
}
}
+invalid:
return hdrlen;
}