From 01017da63c1c0d4b241ea29a43e5d5bd1a3a53dd Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Mon, 19 Nov 2018 16:02:40 +0100 Subject: [PATCH] Revert "Ethernet: Remove two useless tests" 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/print-ether.c b/print-ether.c index 887a8eee..d6dd9572 100644 --- a/print-ether.c +++ b/print-ether.c @@ -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); -- 2.39.5