]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ospf6: note some places where subtraction won't underflow.
authorGuy Harris <[email protected]>
Wed, 27 May 2020 09:18:38 +0000 (02:18 -0700)
committerGuy Harris <[email protected]>
Wed, 27 May 2020 09:18:38 +0000 (02:18 -0700)
print-ospf6.c

index c94a77930d8459f46a7c76f36e507e7f67d93dc3..5c0b090d1139130b1dbb50c23e21dff337efeb21 100644 (file)
@@ -574,6 +574,11 @@ ospf6_print_lsa(netdissect_options *ndo,
                        bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                        if (bytelen < 0)
                                goto trunc;
                        bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                        if (bytelen < 0)
                                goto trunc;
+                       /*
+                        * ospf6_print_lsaprefix() will return -1 if
+                        * the length is too high, so this will not
+                        * underflow.
+                        */
                        lsa_length -= bytelen;
                        tptr += bytelen;
                }
                        lsa_length -= bytelen;
                        tptr += bytelen;
                }
@@ -596,6 +601,11 @@ ospf6_print_lsa(netdissect_options *ndo,
                bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                if (bytelen < 0)
                        goto trunc;
                bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                if (bytelen < 0)
                        goto trunc;
+               /*
+                * ospf6_print_lsaprefix() will return -1 if
+                * the length is too high, so this will not
+                * underflow.
+                */
                lsa_length -= bytelen;
                tptr += bytelen;
 
                lsa_length -= bytelen;
                tptr += bytelen;
 
@@ -657,6 +667,11 @@ ospf6_print_lsa(netdissect_options *ndo,
                        if (bytelen < 0)
                                goto trunc;
                        prefixes--;
                        if (bytelen < 0)
                                goto trunc;
                        prefixes--;
+                       /*
+                        * ospf6_print_lsaprefix() will return -1 if
+                        * the length is too high, so this will not
+                        * underflow.
+                        */
                        lsa_length -= bytelen;
                        tptr += bytelen;
                }
                        lsa_length -= bytelen;
                        tptr += bytelen;
                }
@@ -685,6 +700,11 @@ ospf6_print_lsa(netdissect_options *ndo,
                        if (bytelen < 0)
                                goto trunc;
                        prefixes--;
                        if (bytelen < 0)
                                goto trunc;
                        prefixes--;
+                       /*
+                        * ospf6_print_lsaprefix() will return -1 if
+                        * the length is too high, so this will not
+                        * underflow.
+                        */
                        lsa_length -= bytelen;
                        tptr += bytelen;
                }
                        lsa_length -= bytelen;
                        tptr += bytelen;
                }