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

Add a test file showing the problem.

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

index aba243ddb6f252251be5649fa5decdeccf0b4e4a..38505355182ca15067ea3e0b6ac76a8345cc6ece 100644 (file)
@@ -1131,7 +1131,7 @@ print_ipcp_config_options(netdissect_options *ndo,
                        print_unknown_data(ndo, p + 2, "\n\t    ", len - 2);
                break;
        }
-       if (ndo->ndo_vflag > 1)
+       if (ndo->ndo_vflag > 1 && ND_TTEST_LEN(p + 2, len - 2))
                print_unknown_data(ndo, p + 2, "\n\t    ", len - 2); /* exclude TLV header */
        return len;
 
index 00576f70724762ee6e471cb48fa8aa5b5ac6dd68..bc23b5487bb54aa40cc803caab6145e1ff79ff96 100644 (file)
@@ -190,6 +190,9 @@ babel_pad1      babel_pad1.pcap        babel_pad1.out
 babel_rtt       babel_rtt.pcap         babel_rtt.out   -v
 babel_rfc6126bis  babel_rfc6126bis.pcap  babel_rfc6126bis.out     -v
 
+# PPP tests
+ppp_error_hexdump ppp_error_hexdump.pcap ppp_error_hexdump.out -vv
+
 # PPPoE tests
 pppoe           pppoe.pcap             pppoe.out
 pppoes          pppoes.pcap            pppoes.out
diff --git a/tests/ppp_error_hexdump.out b/tests/ppp_error_hexdump.out
new file mode 100644 (file)
index 0000000..b75a564
--- /dev/null
@@ -0,0 +1,19 @@
+    1  [Error converting time] unknown PPP protocol (0x7e80): IPCP, Conf-Request (0x01), id 0, length 48
+       encoded length 45 (=Option(s) length 41)
+       0x0000:  8021 0100 002d
+         unknown Option (0x66), length 4
+           0x0000:  006c
+         unknown Option (0x72), length 8
+           0x0000:  0055 00d4 c3b2
+         unknown Option (0xa1), length 2
+         IP-Comp Option (0x02), length 32: IP Header Compression (0x61):
+           TCP Space 514, non-TCP Space 514, maxPeriod 514, maxTime 514, maxHdr 52702
+             Suboptions, length 18
+               Enhanced RTP-Compression Suboption #2, length 1
+               RTP-Compression Suboption #1, length 1
+               RTP-Compression Suboption #1, length 1
+               RTP-Compression Suboption #1, length 1
+               RTP-Compression Suboption #1, length 1
+               RTP-Compression Suboption #1, length 1
+               RTP-Compression Suboption #1, length 1
+               RTP-Compression Suboption #1, length 10 [remaining options length 27 < 32] (invalid)
diff --git a/tests/ppp_error_hexdump.pcap b/tests/ppp_error_hexdump.pcap
new file mode 100644 (file)
index 0000000..3ad0a32
Binary files /dev/null and b/tests/ppp_error_hexdump.pcap differ