diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2023-04-27 13:19:34 +0200 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2023-04-27 13:32:26 +0200 |
commit | ef2869ecb72f85fbb452094b45fa53743a23d086 (patch) | |
tree | 2c4fc0737380e5928095e0b44c3db312dff2105f | |
parent | 07d67623862270c21a6f3556a25732e9f09b9f6a (diff) | |
download | tcpdump-ef2869ecb72f85fbb452094b45fa53743a23d086.tar.gz |
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.
-rw-r--r-- | print-ppp.c | 2 | ||||
-rw-r--r-- | tests/TESTLIST | 3 | ||||
-rw-r--r-- | tests/ppp_error_hexdump.out | 19 | ||||
-rw-r--r-- | tests/ppp_error_hexdump.pcap | bin | 0 -> 91 bytes |
4 files changed, 23 insertions, 1 deletions
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 Binary files differnew file mode 100644 index 00000000..3ad0a32b --- /dev/null +++ b/tests/ppp_error_hexdump.pcap |