Skip to content

Fix truncated Telnet and TLS hello reads#2161

Open
ZX41R wants to merge 2 commits into
seladb:devfrom
ZX41R:fix-truncated-telnet-tls-reads
Open

Fix truncated Telnet and TLS hello reads#2161
ZX41R wants to merge 2 commits into
seladb:devfrom
ZX41R:fix-truncated-telnet-tls-reads

Conversation

@ZX41R

@ZX41R ZX41R commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Two parser accessors assumed optional bytes were present after the minimal message header:

  • SSL ClientHello version access read the hello version even when the message only contained the handshake header. I added the same short-buffer guard to the server-hello path as well.
  • Telnet field sizing returned 3 bytes for WILL/WONT/DO/DONT even if the packet ended after the command byte. The option helpers now treat that as a truncated command with no option.

The valid-packet path is unchanged. Truncated inputs now return the existing fallback values instead of reading past the available data.

Fixes #2151.
Fixes #2152.

Testing

  • cmake -S . -B build-asan -DPCAPPP_BUILD_PCAPPP=OFF -DPCAPPP_BUILD_EXAMPLES=OFF -DPCAPPP_BUILD_TESTS=ON -DPCAPPP_BUILD_FUZZERS=OFF -DPCAPPP_USE_SANITIZER=AddressSanitizer -DCMAKE_BUILD_TYPE=Debug
  • cmake --build build-asan --target Packet++Test -j 2
  • env ASAN_OPTIONS=detect_leaks=0 ./Packet++Test -t "ssl;telnet"
  • env ASAN_OPTIONS=detect_leaks=0 ./Packet++Test

I disabled LSAN for these runs because the test binary uses MemPlumber/backtrace allocation tracking; with leak detection enabled the tests themselves pass, then LSAN reports allocations from that tracking path at process exit.

@ZX41R ZX41R requested a review from seladb as a code owner June 9, 2026 23:34
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.73%. Comparing base (6ba29cf) to head (4185c1f).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2161      +/-   ##
==========================================
+ Coverage   82.72%   82.73%   +0.01%     
==========================================
  Files         332      332              
  Lines       59807    59751      -56     
  Branches    12591    12302     -289     
==========================================
- Hits        49475    49436      -39     
- Misses       8947     8963      +16     
+ Partials     1385     1352      -33     
Flag Coverage Δ
23.11.6 7.28% <0.00%> (+<0.01%) ⬆️
24.11.5 7.30% <0.00%> (-0.01%) ⬇️
25.11.1 7.31% <0.00%> (-0.01%) ⬇️
alpine320 76.90% <100.00%> (+0.04%) ⬆️
fedora42 76.50% <100.00%> (+0.07%) ⬆️
macos-14 82.30% <100.00%> (+0.03%) ⬆️
macos-15 82.29% <100.00%> (+0.03%) ⬆️
mingw32 71.17% <100.00%> (+0.05%) ⬆️
mingw64 71.15% <100.00%> (+0.14%) ⬆️
npcap ?
rhel94 76.29% <100.00%> (+0.04%) ⬆️
ubuntu2204 76.33% <100.00%> (+0.06%) ⬆️
ubuntu2204-icpx 59.45% <100.00%> (+0.05%) ⬆️
ubuntu2404 76.61% <100.00%> (+0.04%) ⬆️
ubuntu2404-arm64 76.59% <100.00%> (+0.02%) ⬆️
ubuntu2604 76.51% <100.00%> (+<0.01%) ⬆️
unittest 82.73% <100.00%> (+0.01%) ⬆️
windows-2022 85.83% <100.00%> (+0.14%) ⬆️
windows-2025 ?
winpcap 85.83% <100.00%> (-0.07%) ⬇️
xdp 53.20% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant