Skip to content

fix(pcapng): rebuild a block's info with the options and trailer its parse read (#2776) - #2778

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2776-pcapng-trailer-info
Nov 4, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2776-pcapng-trailer-info

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

A PCAP-NG block with octets after opt_endofopt rebuilt to exact octets, but its rebuilt info lost padding_opts and every option. PCAPNG._make_options_trailer put the trailer into options as raw bytes, and on unpack, _read_pcapng_options treated that entry as an area kept as captured and returned no options.

Closes #2776

…parse read (#2776)

PCAPNG._make_options_trailer appended the octets after opt_endofopt to the
options as raw bytes. A rebuilt block's info is read off the schema make()
built, where _read_pcapng_options takes a bytes item for an area kept as
captured, so from_data(info) and from_data(info.to_dict()) lost every option
and padding_opts on SHB, IDB, PB, NRB, ISB, EPB and DSB, octets intact.

The trailer now goes in the padding field after the options, where the
parse reads it: _make_options_trailer only counts it for the block length,
and each of those makers writes it back through _make_padding.

test_pcapng_trailer_info_2776_unit asserts from_data(info).info == info,
from info and to_dict(), for every #1437 case; 14 subtests fail without it.
@JarryShaw JarryShaw added 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 Nov 4, 2026
@JarryShaw JarryShaw added the review: running A cross-review is in flight against the current head - no verdict yet label Nov 4, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.6 milestone Nov 4, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 4, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 060cdea43 (Sonnet cross-review, plus my own run of the new test)

  • All seven block types (SHB, IDB, EPB, PB, ISB, NRB, DSB) now rebuild with from_data(info).info == info from both info and to_dict(), with exact octets. padding_opts and the options are kept. On main every one of these failed.
  • Unchanged against main: fresh builds with no parsed block (same octets and lengths), the 14 fix(corekit): PaddingField sites outside #1223 still zero-fill their padding on rebuild #1437 cases without a trailer, and an all-zero IDB trailer.
  • Callers: _make_options_trailer's narrowed signature has no callers outside pcapng/protocol.py.
  • Tests: the new module fails on main with 14 failures. All 31 test_pcapng* modules pass, as do every tests/foundation/engines module, the PCAP-NG integration test, Project tests, Lint and deploy-pages.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 4, 2026
@JarryShaw
JarryShaw merged commit 17a5b98 into main Nov 4, 2026
65 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 4, 2026
@JarryShaw
JarryShaw deleted the fix/2776-pcapng-trailer-info branch November 4, 2026 19:14
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 4, 2026
JarryShaw added a commit that referenced this pull request Nov 4, 2026
- #2777: the cut-header sentence reads the length back too, the rebuild read
  at the width its parse was given (__short_width__); the ruling into the
  conventions entry.
- #2778: a PCAP-NG block with octets after opt_endofopt rebuilds an info
  holding its options and padding_opts, where 1.5.1 rebuilt none, into the
  whole-header rebuild entry; 1.5.0's frozen entry is left as written.
- #2779: SCTP's reorder, the source-ordered member lists and the sorted
  Option.register clash warning ('opt', 'if', 'epb', ... in 1.5.1), into the
  member-order entry; the layer-grouped registry and the warning name restore
  ('put back silently' in 1.5.1), into the #2770 entry; the page wording into
  the conventions entry.
- #2781: import_lock serialising first resolutions, into the lazy-import
  entry; the removed registry lock never shipped and stays unnamed.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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): a block rebuilt from its info drops padding_opts and its options after opt_endofopt

1 participant