]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BRCMTAG: Use ND_TCHECK_LEN() for a bounds check
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 17 Oct 2020 12:01:14 +0000 (14:01 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 17 Oct 2020 12:37:29 +0000 (14:37 +0200)
Moreover:
Add a missing ndo_ll_hdr_len increment.
Define ND_LONGJMP_FROM_TCHECK.

print-brcmtag.c

index 1e0c5884436822e2f24b6d17f3a6b197d0beb390..efc6a1eefa46f3ef83f2715cbec70deca780a0b6 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "ethertype.h"
 #include "addrtoname.h"
@@ -131,11 +132,8 @@ brcm_tag_prepend_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
        u_int length = h->len;
 
        ndo->ndo_protocol = "brcm-tag-prepend";
-       if (caplen < BRCM_TAG_LEN) {
-               ndo->ndo_ll_hdr_len += caplen;
-               nd_print_trunc(ndo);
-               return;
-       }
+       ND_TCHECK_LEN(p, BRCM_TAG_LEN);
+       ndo->ndo_ll_hdr_len += BRCM_TAG_LEN;
 
        if (ndo->ndo_eflag) {
                /* Print the prepended Broadcom tag. */