]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rsvp.c
Try the new ND_LCHECK*() macros. [skip ci]
[tcpdump] / print-rsvp.c
index 23b6d5a77386b7542ef3cf8223bf05b3bf717c11..86744e063b9cb54ebdc2eb23dd8842125cb70c5e 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -518,8 +519,7 @@ rsvp_intserv_print(netdissect_options *ndo,
        uint32_t i;
     } bw;
 
-    if (obj_tlen < 4)
-        return 0;
+    ND_LCHECK_U(obj_tlen, 4);
     parameter_id = GET_U_1(tptr);
     parameter_length = GET_BE_U_2(tptr + 2)<<2; /* convert wordcount to bytecount */
 
@@ -529,8 +529,7 @@ rsvp_intserv_print(netdissect_options *ndo,
            parameter_length,
            GET_U_1(tptr + 1));
 
-    if (obj_tlen < parameter_length+4)
-        return 0;
+    ND_LCHECK_U(obj_tlen, parameter_length + 4);
     switch(parameter_id) { /* parameter_id */
 
     case 4:
@@ -608,7 +607,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         */
 
         if (parameter_length == 20) {
-           ND_TCHECK_LEN(tptr + 4, 20);
             bw.i = GET_BE_U_4(tptr + 4);
             ND_PRINT("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000);
             bw.i = GET_BE_U_4(tptr + 8);
@@ -634,7 +632,6 @@ rsvp_intserv_print(netdissect_options *ndo,
         */
 
         if (parameter_length == 8) {
-           ND_TCHECK_8(tptr + 4);
             bw.i = GET_BE_U_4(tptr + 4);
             ND_PRINT("\n\t\tRate: %.10g Mbps", bw.f / 125000);
             ND_PRINT("\n\t\tSlack Term: %u", GET_BE_U_4(tptr + 8));
@@ -656,8 +653,8 @@ rsvp_intserv_print(netdissect_options *ndo,
     }
     return (parameter_length+4); /* header length 4 bytes */
 
-trunc:
-    nd_print_trunc(ndo);
+invalid:
+    nd_print_invalid(ndo);
     return 0;
 }
 
@@ -699,9 +696,6 @@ rsvp_obj_print(netdissect_options *ndo,
     u_int action, subchannel;
 
     while(tlen>=sizeof(struct rsvp_object_header)) {
-        /* did we capture enough for fully decoding the object header ? */
-        ND_TCHECK_LEN(tptr, sizeof(struct rsvp_object_header));
-
         rsvp_obj_header = (const struct rsvp_object_header *)tptr;
         rsvp_obj_len=GET_BE_U_2(rsvp_obj_header->length);
         rsvp_obj_ctype=GET_U_1(rsvp_obj_header->ctype);
@@ -1133,7 +1127,6 @@ rsvp_obj_print(netdissect_options *ndo,
                                ND_PRINT(" ERROR: length != 8");
                                goto invalid;
                        }
-                       ND_TCHECK_8(obj_tptr);
                         ND_PRINT(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
                                bittok2str(rsvp_obj_rro_label_flag_values,
                                    "none",
@@ -1259,8 +1252,7 @@ rsvp_obj_print(netdissect_options *ndo,
                      * each iteration subobj_len may happen to be a multiple of 1
                      * and test it and total_subobj_len respectively.
                      */
-                    if (total_subobj_len < 4)
-                        goto invalid;
+                    ND_LCHECK_U(total_subobj_len, 4);
                     subobj_len  = GET_BE_U_2(obj_tptr);
                     subobj_type = (GET_BE_U_2(obj_tptr + 2))>>8;
                     af = (GET_BE_U_2(obj_tptr + 2))&0x00FF;
@@ -1911,9 +1903,6 @@ obj_tooshort:
 invalid:
     nd_print_invalid(ndo);
     return -1;
-trunc:
-    nd_print_trunc(ndo);
-    return -1;
 }
 
 void
@@ -2062,8 +2051,4 @@ rsvp_print(netdissect_options *ndo,
         print_unknown_data(ndo, tptr, "\n\t    ", tlen);
         break;
     }
-
-    return;
-trunc:
-    nd_print_trunc(ndo);
 }