From: Francois-Xavier Le Bail Date: Fri, 18 Oct 2024 10:07:36 +0000 (+0200) Subject: Juniper: Use the ND_ICHECKMSG_U() macro for a length check X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/07a730a6f5d7d92d34cd7b137fa7fc21505f8441 Juniper: Use the ND_ICHECKMSG_U() macro for a length check It displays the reason for the "invalid" case. Before: 1 2015-05-19 13:34:16.720640 (invalid) After: 1 2015-05-19 13:34:16.720640 [cookie length 10 > 8] (invalid) This is a follow-up to 8c7221d39b44502999c78200d544665f13b4e331. Add the poc test file from GitHub issue #783 (first packet). Moreover: Remove some extra blank lines. --- diff --git a/print-juniper.c b/print-juniper.c index d9bc1f52..19480758 100644 --- a/print-juniper.c +++ b/print-juniper.c @@ -890,7 +890,6 @@ juniper_mlppp_if_print(netdissect_options *ndo, } #endif - #ifdef DLT_JUNIPER_MFR void juniper_mfr_if_print(netdissect_options *ndo, @@ -1272,12 +1271,10 @@ juniper_parse_header(netdissect_options *ndo, int tlv_value; const u_char *tptr; - l2info->header_len = 0; l2info->cookie_len = 0; l2info->proto = 0; - l2info->length = h->len; l2info->caplen = h->caplen; l2info->flags = GET_U_1(p + 3); @@ -1429,7 +1426,6 @@ juniper_parse_header(netdissect_options *ndo, break; } - #ifdef DLT_JUNIPER_MFR /* MFR child links don't carry cookies */ if (l2info->pictype == DLT_JUNIPER_MFR && @@ -1447,10 +1443,7 @@ juniper_parse_header(netdissect_options *ndo, lp->s, l2info->cookie_len); - if (l2info->cookie_len > 8) { - nd_print_invalid(ndo); - return 0; - } + ND_ICHECKMSG_U("cookie length", l2info->cookie_len, >, 8); if (l2info->cookie_len > 0) { ND_TCHECK_LEN(p, l2info->cookie_len); @@ -1464,7 +1457,6 @@ juniper_parse_header(netdissect_options *ndo, if (ndo->ndo_eflag) ND_PRINT(": "); /* print demarc b/w L2/L3*/ - l2info->proto = GET_BE_U_2(p + l2info->cookie_len); } p+=l2info->cookie_len; diff --git a/tests/TESTLIST b/tests/TESTLIST index b316aa9d..a1d71c6f 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -984,3 +984,6 @@ bgp-ub bgp-ub.pcap bgp-ub.out -v # AccECN tests accecn_handshake accecn_handshake.pcap accecn_handshake.out -v + +# Juniper tests +juniper_monitor_invalid_cookie_length juniper_monitor_invalid_cookie_length.pcap juniper_monitor_invalid_cookie_length.out diff --git a/tests/juniper_monitor_invalid_cookie_length.out b/tests/juniper_monitor_invalid_cookie_length.out new file mode 100644 index 00000000..76d94e35 --- /dev/null +++ b/tests/juniper_monitor_invalid_cookie_length.out @@ -0,0 +1 @@ + 1 2015-05-19 13:34:16.720640 [cookie length 10 > 8] (invalid) diff --git a/tests/juniper_monitor_invalid_cookie_length.pcap b/tests/juniper_monitor_invalid_cookie_length.pcap new file mode 100644 index 00000000..fa59eac4 Binary files /dev/null and b/tests/juniper_monitor_invalid_cookie_length.pcap differ