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 8c7221d39b.

Add the poc test file from GitHub issue #783 (first packet).

Moreover:
Remove some extra blank lines.
This commit is contained in:
Francois-Xavier Le Bail 2024-10-18 12:07:36 +02:00
parent 6fa624334b
commit 07a730a6f5
4 changed files with 5 additions and 9 deletions

View File

@ -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;

View File

@ -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

View File

@ -0,0 +1 @@
1 2015-05-19 13:34:16.720640 [cookie length 10 > 8] (invalid)

Binary file not shown.