X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b73d5ba2125bb5f0a6c42afd7542acab0cab320f..82cfcd4391f9f6c748634bfd7b48a44f42e6a53d:/print-ether.c diff --git a/print-ether.c b/print-ether.c index 3aeda8f7..5607bfc3 100644 --- a/print-ether.c +++ b/print-ether.c @@ -86,7 +86,7 @@ const struct tok ethertype_values[] = { { ETHERTYPE_PPPOED, "PPPoE D" }, { ETHERTYPE_PPPOES, "PPPoE S" }, { ETHERTYPE_EAPOL, "EAPOL" }, - { ETHERTYPE_RRCP, "RRCP" }, + { ETHERTYPE_REALTEK, "Realtek protocols" }, { ETHERTYPE_MS_NLB_HB, "MS NLB heartbeat" }, { ETHERTYPE_JUMBO, "Jumbo" }, { ETHERTYPE_NSH, "NSH" }, @@ -150,14 +150,15 @@ ether_common_print(netdissect_options *ndo, const u_char *p, u_int length, int llc_hdrlen; struct lladdr_info src, dst; + if (length < caplen) { + ND_PRINT("[length %u < caplen %u]", length, caplen); + nd_print_invalid(ndo); + return length; + } if (caplen < ETHER_HDRLEN + switch_tag_len) { nd_print_trunc(ndo); return caplen; } - if (length < ETHER_HDRLEN + switch_tag_len) { - nd_print_trunc(ndo); - return length; - } if (print_encap_header != NULL) (*print_encap_header)(ndo, encap_header_arg); @@ -221,7 +222,7 @@ recurse: } int ret = macsec_print(ndo, &p, &length, &caplen, &hdrlen, - &src, &dst); + &src, &dst); if (ret == 0) { /* Payload is encrypted; print it as raw data. */ @@ -237,6 +238,7 @@ recurse: */ length_type = GET_BE_U_2(p); + ND_ICHECK_U(caplen, <, 2); length -= 2; caplen -= 2; p += 2; @@ -402,6 +404,7 @@ recurse: ND_DEFAULTPRINT(p, caplen); } } +invalid: return hdrlen; } @@ -581,8 +584,8 @@ ethertype_print(netdissect_options *ndo, eapol_print(ndo, p); return (1); - case ETHERTYPE_RRCP: - rrcp_print(ndo, p, length, src, dst); + case ETHERTYPE_REALTEK: + rtl_print(ndo, p, length, src, dst); return (1); case ETHERTYPE_PPP: