switch(tlv_type) {
case LS_OPAQUE_TE_TLV_LINK:
- while (tlv_length >= sizeof(subtlv_type) + sizeof(subtlv_length)) {
+ while (tlv_length != 0) {
if (tlv_length < 4) {
ND_PRINT("\n\t Remaining TLV length %u < 4",
tlv_length);
subtlv_type,
subtlv_length);
+ if (tlv_length < subtlv_length) {
+ ND_PRINT("\n\t Remaining TLV length %u < %u",
+ tlv_length + 4, subtlv_length + 4);
+ return -1;
+ }
ND_TCHECK_LEN(tptr, subtlv_length);
switch(subtlv_type) {
case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
if (subtlv_length%4 != 0)
subtlv_length+=4-(subtlv_length%4);
+ if (tlv_length < subtlv_length) {
+ ND_PRINT("\n\t Remaining TLV length %u < %u",
+ tlv_length + 4, subtlv_length + 4);
+ return -1;
+ }
tlv_length-=subtlv_length;
tptr+=subtlv_length;
/* in OSPF everything has to be 32-bit aligned, including TLVs */
if (tlv_length%4 != 0)
tlv_length+=4-(tlv_length%4);
+ if (tlv_length > ls_length) {
+ ND_PRINT("\n\t Bogus padded length %u > %u", tlv_length,
+ ls_length);
+ return -1;
+ }
ls_length-=tlv_length;
tptr+=tlv_length;
}