Repository navigation
fix(protocols): a payload layer parsed from a short stream rebuilds default-filled octets - #1171
Merged
Merged
Conversation
…efault-filled octets Every _import_next_layer picked NoPayload only for a declared length of zero, so a payload captured short of the next layer's header was parsed into zero-filled fields that from_data then rebuilt. One shared helper, ProtocolBase._parse_next_layer, now backs the ProtocolBase, Internet and IPv6 implementations: no captured octets gives NoPayload, and fewer than the next layer's __length_hint__ gives Raw, unless the header it parsed fits anyway (the L2TPv2 hint is its longest form). test.pcapng frame 3, cut inside the IPv4 header, is now Ethernet:Raw, so the two tests that pinned its zero-filled IPv4 rebuild are updated. Closes #1170
Contributor
|
Coverage: 88.89% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Cross-review verdict on
|
This was referenced Oct 7, 2026
fix(protocols): a declared length running past the data is accepted and zero-filled on rebuild
#1325
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make pylint,make mypy,make isort) — run on the 3 changed source files; no new messages vsmainmake testpasses, and a test case covers the change — per module only, listed below; not the fullmake testdocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, added centrally after the waveWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1170. All three
_import_next_layer(ProtocolBase,Internet,IPv6) now shareProtocolBase._parse_next_layer. No captured octets givesNoPayload. Fewer than the next layer's__length_hint__givesRaw, unless the parsed header fits anyway (the L2TPv2 hint, 16, is its longest form, and a 12-octet ZLB staysL2TPv2).IPv6:UDP:Raw, rebuilds 48IPv6, 40Raw)test.pcapngframe 3 (18 IPv4 octets)Ethernet:IPv4, rebuilds 20Ethernet:Raw, byte for byteFrame 3 changes chain, so the #1166 and #1169 tests that pinned its zero-filled IPv4 rebuild now pin the
Rawpayload instead.from_datasweep overexamples/captures/(1612 frames). IPv4 header/full mismatches go from 1/1362 to 0/1361, UDP stays 0/103, TCP 0/1259, IPv6 0 / 183 (pre-existing). No new mismatches. The only chain change is frame 3.Tests: the new
tests/protocols/test_next_layer_short_header_unit.pygives 7 passed; onmain, 5 fail. Also ran ipv4 truncated (3 passed), declared-length (6), internet_unit, protocol_base, ipv4/ipv6/tcp_udp/pcapng_regression, andtests/project(389 passed, 1 skipped). Ordering legs:protocols (rest)shows the same 2F/17E before and after (all pre-existing);protocols/internetis 468, 0 failures, before and after.