]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ospf: when processing LS_OPAQUE_TYPE_RI, don't modify ls_length.
authorGuy Harris <[email protected]>
Wed, 27 May 2020 05:23:33 +0000 (22:23 -0700)
committerGuy Harris <[email protected]>
Wed, 27 May 2020 05:23:33 +0000 (22:23 -0700)
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.

print-ospf.c

index 43f9dcc2e1b041fb19550bda68ac0bf4b78d823a..3f8811efd3c1e04a4bb7d123263d45f8d6ebf467 100644 (file)
@@ -806,25 +806,26 @@ ospf_print_lsa(netdissect_options *ndo,
             case LS_OPAQUE_TYPE_RI:
                tptr = (const uint8_t *)(lsap->lsa_un.un_ri_tlv);
 
-               while (ls_length != 0) {
+               int ls_length_remaining = ls_length;
+               while (ls_length_remaining != 0) {
                     ND_TCHECK_4(tptr);
-                   if (ls_length < 4) {
-                        ND_PRINT("\n\t    Remaining LS length %u < 4", ls_length);
+                   if (ls_length_remaining < 4) {
+                        ND_PRINT("\n\t    Remaining LS length %u < 4", ls_length_remaining);
                         return(ls_end);
                     }
                     tlv_type = GET_BE_U_2(tptr);
                     tlv_length = GET_BE_U_2(tptr + 2);
                     tptr+=4;
-                    ls_length-=4;
+                    ls_length_remaining-=4;
 
                     ND_PRINT("\n\t    %s TLV (%u), length: %u, value: ",
                            tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
                            tlv_type,
                            tlv_length);
 
-                    if (tlv_length > ls_length) {
-                        ND_PRINT("\n\t    Bogus length %u > %u", tlv_length,
-                            ls_length);
+                    if (tlv_length > ls_length_remaining) {
+                        ND_PRINT("\n\t    Bogus length %u > remaining LS length %u", tlv_length,
+                            ls_length_remaining);
                         return(ls_end);
                     }
                     ND_TCHECK_LEN(tptr, tlv_length);
@@ -847,7 +848,7 @@ ospf_print_lsa(netdissect_options *ndo,
 
                     }
                     tptr+=tlv_length;
-                    ls_length-=tlv_length;
+                    ls_length_remaining-=tlv_length;
                 }
                 break;