]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-arp.c
ZEP: Add a bounds check
[tcpdump] / print-arp.c
index 02eb6e4be367f9ab33c3f632f14ed34f74250a68..4855332bbae2b88a70b6ef49e4d7a70bb7351eaf 100644 (file)
@@ -27,8 +27,7 @@
 
 #include "netdissect-stdinc.h"
 
-#include <string.h>
-
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "ethertype.h"
@@ -266,11 +265,7 @@ atmarp_print(netdissect_options *ndo,
        pro = ATMPRO(ap);
        op = ATMOP(ap);
 
-       if (!ND_TTEST_LEN(aar_tpa(ap), ATMTPROTO_LEN(ap))) {
-               nd_print_trunc(ndo);
-               ND_DEFAULTPRINT((const u_char *)ap, length);
-               return;
-       }
+       ND_TCHECK_LEN(ATMTPA(ap), ATMTPROTO_LEN(ap));
 
         if (!ndo->ndo_eflag) {
             ND_PRINT("ARP, ");
@@ -286,7 +281,7 @@ atmarp_print(netdissect_options *ndo,
                           ATMSPROTO_LEN(ap),
                           ATMTPROTO_LEN(ap));
 
-                /* don't know know about the address formats */
+                /* don't know about the address formats */
                 if (!ndo->ndo_vflag) {
                     goto out;
                 }
@@ -347,10 +342,6 @@ atmarp_print(netdissect_options *ndo,
 
  out:
         ND_PRINT(", length %u", length);
-        return;
-
-trunc:
-       nd_print_trunc(ndo);
 }
 
 void
@@ -386,11 +377,7 @@ arp_print(netdissect_options *ndo,
             break;
        }
 
-       if (!ND_TTEST_LEN(TPA(ap), PROTO_LEN(ap))) {
-               nd_print_trunc(ndo);
-               ND_DEFAULTPRINT((const u_char *)ap, length);
-               return;
-       }
+       ND_TCHECK_LEN(TPA(ap), PROTO_LEN(ap));
 
         if (!ndo->ndo_eflag) {
             ND_PRINT("ARP, ");
@@ -407,7 +394,7 @@ arp_print(netdissect_options *ndo,
                       tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro),
                       PROTO_LEN(ap));
 
-            /* don't know know about the address formats */
+            /* don't know about the address formats */
             if (!ndo->ndo_vflag) {
                 goto out;
             }
@@ -467,8 +454,4 @@ arp_print(netdissect_options *ndo,
 
  out:
         ND_PRINT(", length %u", length);
-
-       return;
-trunc:
-       nd_print_trunc(ndo);
 }