Skip to content

Commit 07a730a

Browse files
committed
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 8c7221d. Add the poc test file from GitHub issue #783 (first packet). Moreover: Remove some extra blank lines.
1 parent 6fa6243 commit 07a730a

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

print-juniper.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ juniper_mlppp_if_print(netdissect_options *ndo,
890890
}
891891
#endif
892892

893-
894893
#ifdef DLT_JUNIPER_MFR
895894
void
896895
juniper_mfr_if_print(netdissect_options *ndo,
@@ -1272,12 +1271,10 @@ juniper_parse_header(netdissect_options *ndo,
12721271
int tlv_value;
12731272
const u_char *tptr;
12741273

1275-
12761274
l2info->header_len = 0;
12771275
l2info->cookie_len = 0;
12781276
l2info->proto = 0;
12791277

1280-
12811278
l2info->length = h->len;
12821279
l2info->caplen = h->caplen;
12831280
l2info->flags = GET_U_1(p + 3);
@@ -1429,7 +1426,6 @@ juniper_parse_header(netdissect_options *ndo,
14291426
break;
14301427
}
14311428

1432-
14331429
#ifdef DLT_JUNIPER_MFR
14341430
/* MFR child links don't carry cookies */
14351431
if (l2info->pictype == DLT_JUNIPER_MFR &&
@@ -1447,10 +1443,7 @@ juniper_parse_header(netdissect_options *ndo,
14471443
lp->s,
14481444
l2info->cookie_len);
14491445

1450-
if (l2info->cookie_len > 8) {
1451-
nd_print_invalid(ndo);
1452-
return 0;
1453-
}
1446+
ND_ICHECKMSG_U("cookie length", l2info->cookie_len, >, 8);
14541447

14551448
if (l2info->cookie_len > 0) {
14561449
ND_TCHECK_LEN(p, l2info->cookie_len);
@@ -1464,7 +1457,6 @@ juniper_parse_header(netdissect_options *ndo,
14641457

14651458
if (ndo->ndo_eflag) ND_PRINT(": "); /* print demarc b/w L2/L3*/
14661459

1467-
14681460
l2info->proto = GET_BE_U_2(p + l2info->cookie_len);
14691461
}
14701462
p+=l2info->cookie_len;

tests/TESTLIST

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,3 +984,6 @@ bgp-ub bgp-ub.pcap bgp-ub.out -v
984984

985985
# AccECN tests
986986
accecn_handshake accecn_handshake.pcap accecn_handshake.out -v
987+
988+
# Juniper tests
989+
juniper_monitor_invalid_cookie_length juniper_monitor_invalid_cookie_length.pcap juniper_monitor_invalid_cookie_length.out
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2015-05-19 13:34:16.720640 [cookie length 10 > 8] (invalid)
122 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)