]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Revert "Ethernet: Remove two useless tests"
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 19 Nov 2018 15:02:40 +0000 (16:02 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 19 Nov 2018 15:02:40 +0000 (16:02 +0100)
This reverts commit b7fff7058282c332ba1d8d236c9864ab21b16adf (partially)

The sanity check in print.c/pretty_print_packet() function, packet length
(length) >= capture length (caplen), apply when the ether_print()
function is called by ether_if_print(), netanalyzer_if_print() or
netanalyzer_transparent_if_print().

But the ether_print() function is called in some other cases, thus not
sure length always >= caplen.

print-ether.c

index 887a8eee91b140da1a188a208c256e8b7089dbad..d6dd957242bd006cf7aa4ab6ccd8c060a28a7d26 100644 (file)
@@ -163,6 +163,10 @@ ether_print(netdissect_options *ndo,
                nd_print_trunc(ndo);
                return (caplen);
        }
+       if (length < ETHER_HDRLEN) {
+               nd_print_trunc(ndo);
+               return (length);
+       }
 
        if (ndo->ndo_eflag) {
                if (print_encap_header != NULL)
@@ -210,6 +214,11 @@ recurse:
                        nd_print_trunc(ndo);
                        return (hdrlen + caplen);
                }
+               if (length < 4) {
+                       ndo->ndo_protocol = "vlan";
+                       nd_print_trunc(ndo);
+                       return (hdrlen + length);
+               }
                if (ndo->ndo_eflag) {
                        uint16_t tag = EXTRACT_BE_U_2(p);