Skip to content

fix(reassembly): an IP datagram over 65,535 octets can read COMPLETE but short, or vanish in strict mode #1566

Closed

Description

@JarryShaw

An IP datagram longer than 65,535 octets can be reported COMPLETE with its tail missing. In strict mode, a fragment clipped at the buffer edge can make the datagram disappear entirely. These were found in the #1564 review and re-measured on its head, e7c9e5fba. On main, the same inputs raise IndexError instead (#1565).

COMPLETE but short.

  • Input: fragments covering octets 0–65527, then a malformed 7-octet MF=1 fragment at offset 65528 (TL 27), then a final fragment at offset 64 with TL 65535.
  • The total data length (TDL) is 65,579, yet the datagram reads COMPLETE with 65,535 octets, in both strict and lax mode.
  • Cause: both completion checks test all(RCVBT[0:(TDL + 7) // 8]), and that slice silently stops at RCVBT's 8,192 entries (pcapkit/foundation/reassembly/ip.py:230-232 and :334-336 on e7c9e5fba).

Silent drop in strict mode.

  • Input: an 8-octet MF=1 fragment at offset 65528 (TL 28) is clipped to 7 octets by the buffer (:185).
  • The check held != length then sets no RCVBT bit (:215). Strict mode returns no datagram at all, and lax mode returns an empty PARTIAL one.
  • A 7-octet fragment at the same offset is reported. One extra octet changes the outcome.

Expected: a datagram that cannot fit is never COMPLETE, and a clipped fragment counts consistently. The reviewer's candidate fix is to require stop <= len(RCVBT) in both completion checks. In a scratch tree, that turns the first repro into PARTIAL while a legitimate 65,523-octet datagram still completes.

Blocked until #1564 merges, because the fix is in the same file.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 10, 2026
  2. moved this to Blocked in PyPCAPKiton Oct 10, 2026
  3. JarryShaw commented on Oct 10, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1564 has merged (e0d3c8512). One worker is fixing this together with #1567, because both are in pcapkit/foundation/reassembly/ip.py.

  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 10, 2026
  5. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 10, 2026
  6. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions