From: Francois-Xavier Le Bail Date: Mon, 1 Feb 2021 12:44:21 +0000 (+0100) Subject: PTP: Use ND_LCHECK_U for checking invalid length X-Git-Tag: tcpdump-4.99.2~202 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/c90a33ba010d58463971b3bb01442847cae6525d PTP: Use ND_LCHECK_U for checking invalid length Moreover: Rename a variable. (cherry picked from commit 1c67c0188bc9cd5095154efde3011bb6ac1b3130) --- diff --git a/print-ptp.c b/print-ptp.c index 6f12b90a..f4ccbe9d 100644 --- a/print-ptp.c +++ b/print-ptp.c @@ -431,14 +431,12 @@ ptp_print_2(netdissect_options *ndo, const u_char *bp, u_int length) * PTP general message */ void -ptp_print(netdissect_options *ndo, const u_char *bp, u_int len) +ptp_print(netdissect_options *ndo, const u_char *bp, u_int length) { u_int vers; ndo->ndo_protocol = "ptp"; - if (len < PTP_HDR_LEN) { - goto trunc; - } + ND_LCHECK_U(length, PTP_HDR_LEN); vers = GET_BE_U_2(bp) & PTP_VERS_MASK; ND_PRINT("PTPv%u",vers); switch(vers) { @@ -446,7 +444,7 @@ ptp_print(netdissect_options *ndo, const u_char *bp, u_int len) ptp_print_1(ndo); break; case PTP_VER_2: - ptp_print_2(ndo, bp, len); + ptp_print_2(ndo, bp, length); break; default: //ND_PRINT("ERROR: unknown-version\n"); @@ -454,8 +452,8 @@ ptp_print(netdissect_options *ndo, const u_char *bp, u_int len) } return; -trunc: - nd_print_trunc(ndo); +invalid: + nd_print_invalid(ndo); } static void