From: Francois-Xavier Le Bail Date: Thu, 27 Apr 2023 11:19:34 +0000 (+0200) Subject: PPP: Check if there is some data to hexdump X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/ef2869ecb72f85fbb452094b45fa53743a23d086?ds=inline PPP: Check if there is some data to hexdump This may avoid this error: Dissector error: print_unknown_data() called with pointer past end of packet Add a test file showing the problem. --- diff --git a/print-ppp.c b/print-ppp.c index aba243dd..38505355 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -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; diff --git a/tests/TESTLIST b/tests/TESTLIST index 00576f70..bc23b548 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -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 index 00000000..b75a5642 --- /dev/null +++ b/tests/ppp_error_hexdump.out @@ -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 index 00000000..3ad0a32b Binary files /dev/null and b/tests/ppp_error_hexdump.pcap differ