]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pktap.c
CI: Add warning exemptions for Sun C (suncc-5.15) on Solaris 10
[tcpdump] / print-pktap.c
index 5365617de12bb70d6568918f790fbde4132fb3a0..d1c391d5ce1b21adef3bb814c671f2b3c1f48237 100644 (file)
 
 /* \summary: Apple's DLT_PKTAP printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 
@@ -107,10 +106,10 @@ pktap_if_print(netdissect_options *ndo,
        struct pcap_pkthdr nhdr;
 
        ndo->ndo_protocol = "pktap";
-       if (caplen < sizeof(pktap_header_t)) {
-               nd_print_trunc(ndo);
-               ndo->ndo_ll_hdr_len += caplen;
-               return;
+       if (length < sizeof(pktap_header_t)) {
+               ND_PRINT(" (packet too short, %u < %zu)",
+                        length, sizeof(pktap_header_t));
+               goto invalid;
        }
        hdr = (const pktap_header_t *)p;
        dlt = GET_LE_U_4(hdr->pkt_dlt);
@@ -123,15 +122,16 @@ pktap_if_print(netdissect_options *ndo,
                 * is the length supplied so that the header can
                 * be expanded in the future)?
                 */
-               nd_print_trunc(ndo);
-               ndo->ndo_ll_hdr_len += caplen;
-               return;
+               ND_PRINT(" (pkt_len too small, %u < %zu)",
+                        hdrlen, sizeof(pktap_header_t));
+               goto invalid;
        }
-       if (caplen < hdrlen) {
-               nd_print_trunc(ndo);
-               ndo->ndo_ll_hdr_len += caplen;
-               return;
+       if (hdrlen > length) {
+               ND_PRINT(" (pkt_len too big, %u > %u)",
+                        hdrlen, length);
+               goto invalid;
        }
+       ND_TCHECK_LEN(p, hdrlen);
 
        if (ndo->ndo_eflag)
                pktap_header_print(ndo, p, length);
@@ -168,5 +168,8 @@ pktap_if_print(netdissect_options *ndo,
 
        ndo->ndo_ll_hdr_len += hdrlen;
        return;
+
+invalid:
+       nd_print_invalid(ndo);
 }
 #endif /* DLT_PKTAP */