Skip to content

Commit c3564c6

Browse files
committed
ospf: when processing LS_OPAQUE_TYPE_RI, don't modify ls_length.
Modifying it means that the "print the LSA in hex" code will only print what remains of the LSA - unlike other LSAs, where it's printed in its entirety.
1 parent 351c0ad commit c3564c6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

print-ospf.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -806,25 +806,26 @@ ospf_print_lsa(netdissect_options *ndo,
806806
case LS_OPAQUE_TYPE_RI:
807807
tptr = (const uint8_t *)(lsap->lsa_un.un_ri_tlv);
808808

809-
while (ls_length != 0) {
809+
int ls_length_remaining = ls_length;
810+
while (ls_length_remaining != 0) {
810811
ND_TCHECK_4(tptr);
811-
if (ls_length < 4) {
812-
ND_PRINT("\n\t Remaining LS length %u < 4", ls_length);
812+
if (ls_length_remaining < 4) {
813+
ND_PRINT("\n\t Remaining LS length %u < 4", ls_length_remaining);
813814
return(ls_end);
814815
}
815816
tlv_type = GET_BE_U_2(tptr);
816817
tlv_length = GET_BE_U_2(tptr + 2);
817818
tptr+=4;
818-
ls_length-=4;
819+
ls_length_remaining-=4;
819820

820821
ND_PRINT("\n\t %s TLV (%u), length: %u, value: ",
821822
tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
822823
tlv_type,
823824
tlv_length);
824825

825-
if (tlv_length > ls_length) {
826-
ND_PRINT("\n\t Bogus length %u > %u", tlv_length,
827-
ls_length);
826+
if (tlv_length > ls_length_remaining) {
827+
ND_PRINT("\n\t Bogus length %u > remaining LS length %u", tlv_length,
828+
ls_length_remaining);
828829
return(ls_end);
829830
}
830831
ND_TCHECK_LEN(tptr, tlv_length);
@@ -847,7 +848,7 @@ ospf_print_lsa(netdissect_options *ndo,
847848

848849
}
849850
tptr+=tlv_length;
850-
ls_length-=tlv_length;
851+
ls_length_remaining-=tlv_length;
851852
}
852853
break;
853854

0 commit comments

Comments
 (0)