Skip to content

Commit 01017da

Browse files
committed
Revert "Ethernet: Remove two useless tests"
This reverts commit b7fff70 (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.
1 parent 9edeb14 commit 01017da

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

print-ether.c

+9
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ ether_print(netdissect_options *ndo,
163163
nd_print_trunc(ndo);
164164
return (caplen);
165165
}
166+
if (length < ETHER_HDRLEN) {
167+
nd_print_trunc(ndo);
168+
return (length);
169+
}
166170

167171
if (ndo->ndo_eflag) {
168172
if (print_encap_header != NULL)
@@ -210,6 +214,11 @@ ether_print(netdissect_options *ndo,
210214
nd_print_trunc(ndo);
211215
return (hdrlen + caplen);
212216
}
217+
if (length < 4) {
218+
ndo->ndo_protocol = "vlan";
219+
nd_print_trunc(ndo);
220+
return (hdrlen + length);
221+
}
213222
if (ndo->ndo_eflag) {
214223
uint16_t tag = EXTRACT_BE_U_2(p);
215224

0 commit comments

Comments
 (0)