Repository navigation
fix(pcap): building a frame with snaplen 0 writes a record with no packet data (#1385) - #1410
Merged
Merged
Conversation
…cket data (#1385) Frame.make() defaulted incl_len to min(len(packet), snaplen), so a zero snaplen produced a 16-octet record with no packet data. A zero snaplen is now no limit: the PCAP draft forbids zero, libpcap reads it as the link type maximum (pcapint_adjust_snapshot), and PCAP-NG already treats it so.
Owner
Author
|
Cross-review verdict on
Nits: the PR cites |
Contributor
|
Coverage: 89.40% (unit tier, Python 3.14,
Per-file detail: the |
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) — not run asmake;mypyreports nothing inframe.py,tests/projectisort test passesmake testpasses, and a test case covers the change — the modules listed below, notmake 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 #1385
Frame.make()defaultedincl_lentomin(len(packet), snaplen), so snaplen 0 built a 16-octet record with no data. A zero snaplen now means no limit. Sources: draft-ietf-opsawg-pcap §4 says SnapLen "MUST NOT be zero"; libpcap'spcapint_adjust_snapshot(savefile.c) reads 0 as the link-type maximum; PCAP-NG here already treats 0 as no limit. Changed default inmake()only for snaplen 0; an explicitincl_len, and so parse →from_data→ pack, is unchanged.make(packet=4 octets)under snaplen 0 →…00000000 04000000, no data. After:…04000000 04000000 deadbeef, and it parses and rebuilds byte-exact.tests/protocols/misc/pcap/test_frame_snaplen_zero_1385_unit.py: 3 passed; withorigin/main'sframe.py, 2 failed, 1 passed (the snaplen-2 control).tests/protocols/misc/pcap/*all pass;run_unittest_leg.py foundation522 OK;protocols --exclude protocols/internet1021 OK;tests/integration90 passed, 2 skipped;tests/project399 passed, 1 skipped. All run under a 200 MiB file-size cap.