]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Juniper: Use the ND_ICHECKMSG_U() macro for a length check
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 18 Oct 2024 10:07:36 +0000 (12:07 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 18 Oct 2024 13:34:16 +0000 (15:34 +0200)
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.

print-juniper.c
tests/TESTLIST
tests/juniper_monitor_invalid_cookie_length.out [new file with mode: 0644]
tests/juniper_monitor_invalid_cookie_length.pcap [new file with mode: 0644]

index d9bc1f52dc75fae5ad4ff6d756e7301fc0df0f74..1948075866a9f2e9d8c1e9f58c0fbdd14d99e9c9 100644 (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;
index b316aa9da05cc9533a0cfad3c3bcd65834cf984d..a1d71c6fc4a46aae0c3c900192b208c725bcf0a6 100644 (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
diff --git a/tests/juniper_monitor_invalid_cookie_length.out b/tests/juniper_monitor_invalid_cookie_length.out
new file mode 100644 (file)
index 0000000..76d94e3
--- /dev/null
@@ -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 (file)
index 0000000..fa59eac
Binary files /dev/null and b/tests/juniper_monitor_invalid_cookie_length.pcap differ