Skip to content

fix(tcp): rebuild a TCP header with the End of Option List padding its parse read (#2769) - #2775

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2769-tcp-eool-padding
Nov 4, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2769-tcp-eool-padding

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

TCP.make writes End of Option List padding into options and never sets the schema's padding field. A rebuilt or made TCP header then read padding as b'', where its parse read b'\x00\x00\x00'.

  • TCP.read now slices the padding from the octets after the options, as IPv4.read already does. Only the method body changes, and TCP's 1.6.0 versionchanged block gains one bullet. A header built with make() now reports its alignment zeros as padding, as parsing its own octets does.
  • HOPOPT, IPv6-Opts, MH and SCTP already agree. PCAP-NG drops octets after opt_endofopt on rebuild through its own code. That is filed separately.
  • The new module covers 0–3 octets after EOOL, standalone and inside IPv4, from info and from to_dict(). It fails on main with 16 failures and passes here.

Closes #2769

…s parse read (#2769)

TCP.make writes the octets after an End of Option List inside the options it
builds, through _make_tcp_options, and sets no padding on the schema, so
TCP.read, which took padding from that schema, read a made or rebuilt header's
padding as empty while its octets were exact. TCP.read now slices the padding
from the octets past the options it read, as IPv4.read does, so from_data over
info or to_dict() reads what the parse read.

Adds test_tcp_eool_padding_2769_unit (ALL tier): zero to three octets after
EOOL, zero and non-zero, standalone and inside IPv4, from info and to_dict(),
and a made header against the parse of its own octets.
@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
@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 c1268738f (Sonnet cross-review, and my own run of the new test)

  • Padding after End of Option List: 0–3 octets (zero, 0xff or NOP-valued) rebuild exactly. That holds standalone and inside IPv4 and IPv6, from both info and to_dict(), with or without MSS, NOP or window-scale ahead of EOOL. An options area with no EOOL still gives b''.
  • Random option areas: 459 random parseable areas give 0 mismatches. Main fails 430 of them.
  • make() callers: make() now reports its alignment zeros as padding. No test or caller expected b''.
  • Changelog note: the versionchanged bullet sits in TCP's existing 1.6.0 block. TCP shipped in 1.5.1.
  • Tests: the new module fails on main with 16 failures. Every TCP, MPTCP and option round-trip suite passes, as do 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
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Coverage: 94.45% (unit tier, Python 3.15, c1268738f, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 106 4 20 2 95.24%
pcapkit/const 20918 175 2908 156 98.57%
pcapkit/corekit 2913 77 940 38 96.81%
pcapkit/dumpkit 286 3 102 3 98.45%
pcapkit/foundation 3506 27 1216 32 98.75%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 22830 157 5950 127 99.00%
pcapkit/toolkit 961 26 342 8 96.62%
pcapkit/utilities 559 7 150 5 98.31%
pcapkit/vendor 5590 2286 1280 214 55.75%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 7e65847 into main Nov 4, 2026
70 checks passed
@JarryShaw
JarryShaw deleted the fix/2769-tcp-eool-padding branch November 4, 2026 18:29
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 4, 2026
@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
- Fixed, a new entry beside the cut-header one: a whole header rebuilt
  through from_data reads back what its parse read. An extension header
  parsed with extension=True rebuilds in that mode, where 1.5.x's rebuild
  gained next-layer keys, and a rebuilt Shim6 header keeps its protocol, where
  1.5.x's was None (#2774); a rebuilt or made TCP header reads its padding past
  the End of Option List, where 1.5.x read it as empty (#2775). Both measured
  on a v1.5.1 export.
- 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(tcp): a rebuilt standalone TCP header reads its End of Option List padding as empty

1 participant