]> The Tcpdump Group git mirrors - tcpdump/commitdiff
RIP: Check if there is some data to hexdump
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 27 Apr 2023 06:17:35 +0000 (08:17 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Thu, 27 Apr 2023 06:34:23 +0000 (08:34 +0200)
This may avoid this error:
Dissector error: print_unknown_data() called with pointer past end of
packet

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

index 9e81bb53593199a17e1e5a30659f0ea7e57439c0..57e7e481121e051af0ac09b38aa228d4a8d9b1da 100644 (file)
@@ -385,7 +385,7 @@ rip_print(netdissect_options *ndo,
                break;
        }
        /* do we want to see an additionally hexdump ? */
-       if (ndo->ndo_vflag> 1) {
+       if (ndo->ndo_vflag > 1 && ND_TTEST_LEN(p, len)) {
                if (!print_unknown_data(ndo, p, "\n\t", len))
                        return;
        }
index dbc38425e36c7d0ac4c749668e45a260fe8daf98..00576f70724762ee6e471cb48fa8aa5b5ac6dd68 100644 (file)
@@ -245,6 +245,7 @@ ripv2_auth      ripv2_auth.pcap         ripv2_auth.out  -v
 
 # RIP invalid
 ripv2-invalid-length ripv2-invalid-length.pcap ripv2-invalid-length.out -v
+rip_error_hexdump rip_error_hexdump.pcap rip_error_hexdump.out -vv
 
 # DHCPv6 tests
 dhcpv6-aftr-name       dhcpv6-AFTR-Name-RFC6334.pcap   dhcpv6-AFTR-Name-RFC6334.out    -v
diff --git a/tests/rip_error_hexdump.out b/tests/rip_error_hexdump.out
new file mode 100644 (file)
index 0000000..1bfeef5
--- /dev/null
@@ -0,0 +1,6 @@
+    1  12:11:42.563815 IP (tos 0x0, ttl 64, id 1, offset 0, flags [+, DF], proto UDP (17), length 70, bad cksum 0 (->3903)!)
+    0.254.96.182.520 > 255.127.128.111.65535: 
+       RIPv2, Request, length: 42, routes: 1 or less
+         Unknown (26725) Authentication data:
+         0x0000:  6901 0202 0421 0001 0281 8181 6bd4 c3b2
+         0x0010:  a102
diff --git a/tests/rip_error_hexdump.pcap b/tests/rip_error_hexdump.pcap
new file mode 100644 (file)
index 0000000..618a029
Binary files /dev/null and b/tests/rip_error_hexdump.pcap differ