Skip to content

fix(pcapng)!: default the IDB snaplen to 0 and reject values the field cannot hold (#2278) - #2348

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2278-pcapng-idb-snaplen-default
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2278-pcapng-idb-snaplen-default

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style
  • make test passes, and a test case covers the change
  • Changelog entry: 1.5.0.rst (breaking change)

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2278. Breaking: the default snaplen changes.

  • Fix: _make_block_idb defaulted snaplen to 0xFFFF_FFFF_FFFF_FFFF, which the 32-bit field silently truncated to 0xFFFFFFFF. The default is now 0, and a value outside 0..0xFFFFFFFF raises ProtocolError.
  • Fail-without-fix: 5 failed on origin/main. Passing on the rebased head.

@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: NEEDS CHANGES at b14b04ec7 (Sonnet) — two small gaps, the fix itself is sound.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 27, 2026
…d cannot hold (#2278)

_make_block_idb defaulted snaplen to 2**64 - 1, which the 32-bit SnapLen
field truncates to 0xFFFFFFFF, so the made info disagreed with its octets;
any explicit value outside 32 bits was truncated the same way.

Default to 0 (no limit, per the PCAP-NG spec and the schema's own default)
and raise ProtocolError for a snaplen outside 0..0xFFFFFFFF. Breaking: a
make() without snaplen writes 0. Changelog entry added, CHANGELOG.md
regenerated.

Test: the default writes and reports 0, made info equals the parsed info
for in-range values, and out-of-range values raise.
@JarryShaw
JarryShaw force-pushed the fix/2278-pcapng-idb-snaplen-default branch from b14b04e to 0a2bd83 Compare October 27, 2026 02:11
@JarryShaw

Copy link
Copy Markdown
Owner Author

Amended b14b04ec7 → 0a2bd8393: added the .. versionchanged:: 1.5.0 note to _make_block_idb's docstring, and corrected the PR body's changelog checkbox (it already had a 1.5.0.rst entry). tests/protocols/misc/test_pcapng_idb_snaplen_default_2278_unit.py and tests/test_docstring_contract.py give 11 passed.

Also filed, as separate pre-existing defects found in review (not caused by this PR): #2353 (a raw bytes option in options= raises on self._byte), #2354 (make(block=<bytes>) for a DSB raises a bare AttributeError). The scapy SPB-read-on-SnapLen=0 gap stays a note rather than an issue, under the #1687 best-effort ruling.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 27, 2026
@JarryShaw
JarryShaw merged commit cfc5bbe into main Oct 27, 2026
61 checks passed
@JarryShaw
JarryShaw deleted the fix/2278-pcapng-idb-snaplen-default branch October 27, 2026 04:29
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 2026
JarryShaw added a commit that referenced this pull request Oct 28, 2026
Problem: of the 60 pull requests merged in the #2312-#2407 range, only
#2334, #2336, #2337, #2340 and #2348 wrote a 1.5.0 changelog entry, and
#2398 and #2403 only reworded lines that were already there. Every other
user-visible change in the range -- wire-semantics fixes, maker guards,
reassembly behaviour, public-API and error-message changes -- went
unrecorded, so the entry no longer describes the release.

Fix: one entry per user-visible pull request, in each module section's
existing style and ordered by the issue it closes. Two pairs share a
bullet, since each is the direct follow-up of the other: #2393 with
#2401, and #2405 with #2407. The diff on the entry file is purely
additive.

Internal-only work is left out deliberately: dependency and action bumps
(#2387 to #2391), test-only and docs-prose passes (#2333, #2376, #2379,
#2380, #2402), the unreachable-branch removal (#2378), and the #: comment
marker the HIP Group and Packet crawlers now write (#2381). That last one
renders nothing either way: the marker lands inside the generated
_missing_ body, conf.py's exclude-members drops _missing_ from autodoc,
and a comment in a method body is not an attribute comment to begin with.

#2392 and #2403 are recorded together, under Added rather than Fixed, for
the declarations they introduce: __proto_key__ on the seven classes owning
a __proto__ registry (#2392), __proto_dest__ on the four enum registries
and Vendor.PROTO_DEST to generate it (#2403). Both PRs added the autodoc
entries, so both are rendered public attributes. #2392's rejection-message
change is deliberately not recorded as a fix: the bare "code must be ..."
text it prefixed came from _check_code, which #2193 introduced and which
is in no release tag -- absent at v1.5.0b14 -- so no released version ever
emitted it. #2403 is no longer skipped as internal because it reworded an
existing bullet to name __proto_dest__ while nothing credited the
attribute's introduction.

Four claims are corrected against the source rather than carried over:
FTP_DATA shipped in pcapkit/protocols/application/ftp.py from 1.0.0, not
1.4.0 (class FTP_DATA(Raw) is there at v1.0.0); #2365's pre-fix fallback
read cmmd.value, so a .value-carrying object was accepted unchecked
rather than raising; #2399 left the dpkt adapter and the adapters'
ModuleNotFound raises alone, so it claims no universal prefix; and
#2397's old tail did name the version it got, so the entry quotes it and
gains the :issue:`2302` it was missing. #2370's "a Section Header Block
... still fails" sentence is dropped: #2369 settles the byte order first,
and an SHB built from raw octets with ctx=None now rebuilds byte-exact in
both byte orders.

CHANGELOG.md is regenerated with util/changelog_md.py.

Test: tests/project/ in full, 0 failures, including test_changelog_md.py's
in-step and supported-subset checks; util/changelog_md.py --check reports
the two files in step; the entry parses under docutils with no structural
warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(pcapng): IDB maker defaults snaplen to 2**64-1, which the 32-bit SnapLen truncates

1 participant