Skip to content

fix(reassembly): bound TCP holes with a platform-independent open bound (#1959) - #1965

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1959-tcp-hole-bounds
Oct 20, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1959-tcp-hole-bounds

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 reassembly used sys.maxsize as the open bound of its hole descriptor list. On GraalPy and 32-bit builds that is 2**31 - 1, which lies inside TCP's sequence space. So holes went wrong past 2**31, and a FIN'd stream was never seen as whole (#1959).

  • New pcapkit.foundation.reassembly.data.tcp.HOLE_OPEN_BOUND (2**63 - 1). It stays an int, as HoleDescriptor is typed, and is JSON- and plist-safe in both signs. It equals 64-bit sys.maxsize, so nothing changes where it already worked.
  • It and its negation replace every former sys.maxsize site in reassembly/tcp.py. It is documented on HoleDescriptor and the TCP reassembly page.
  • New regression tests patch sys.maxsize to 2**31 - 1 and drive sequence numbers above 2**31. They fail without the fix.

Closes #1959

…nd (#1959)

- Add `HOLE_OPEN_BOUND` (`2 ** 63 - 1`) to `pcapkit.foundation.reassembly.data.tcp`
  and use it, and its negation, for the open ends of the hole descriptor list
  instead of `sys.maxsize`, which is `2 ** 31 - 1` on GraalPy and 32-bit builds
  and so falls inside the TCP sequence space
- Document the constant on `HoleDescriptor` and the TCP reassembly docs page
- Pin the existing hole-list tests to the constant, and add regression tests
  that patch `sys.maxsize` to `2 ** 31 - 1` with sequence numbers above `2 ** 31`

Closes #1959
@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 Oct 20, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 20, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at c6c370fda. A Sonnet review checked the bound against the sequence space. _unwrap keeps each step within 2**31 of its reference, and every hole first/last is a PSN plus a payload length, so 2**63 - 1 is unreachable in practice. No sys.maxsize remains in pcapkit/, and the four sites use the bound symmetrically. The hole list is never dumped. versionadded:: 1.5.0 matches the unreleased 1.5.0b13. Without the fix, the tests fail on the reported symptom ([(3235779125, 2147483647)]). With it, 320 passed across reassembly, traceflow, tier guard, docstring and public-API tests.

@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 Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 90.07% (unit tier, Python 3.15, c6c370fda, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 19597 881 2618 867 92.11%
pcapkit/corekit 2504 70 792 36 96.54%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2916 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17411 224 4580 189 98.10%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 522 2 158 4 99.12%
pcapkit/vendor 4431 2341 1018 156 43.64%

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

@JarryShaw
JarryShaw merged commit 0afbd1c into main Oct 20, 2026
61 checks passed
@JarryShaw
JarryShaw deleted the fix/1959-tcp-hole-bounds branch October 20, 2026 01:55
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 20, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 20, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
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(reassembly): TCP hole bounds use sys.maxsize, which is 2**31-1 on GraalPy and 32-bit CPython

1 participant