Skip to content

fix(schema): Schema.pack drops the end-of-options padding length, so TCP and IPv4 rebuild shorter than their header says #1289

Closed

Description

@JarryShaw

Describe the bug
Nothing on the pack path sets __option_padding__, so PaddingField(length=lambda pkt: pkt.get("__option_padding__", 0)) resolves to 0 (schema.py:822-824 packs bytes(field.length); fields at schema/transport/tcp.py:1148, schema/internet/ipv4.py:716, and the pcapng option padding in schema/misc/pcapng.py, e.g. :917). Only the length is covered here; the padding octet values are #1223, and the unpack-side padding handling in #1229 is a different path.

To Reproduce
Rebuild with TCP.from_schema(tcp.schema.to_dict()):

  • tcp.pcap frame 1: 44 -> 43 octets (...04020000 -> ...040200), Data Offset still 11.
  • many_interfaces.pcapng frames 24 and 52: the same 44 -> 43.
  • IPv4 460000180000000040060000c0a80001c0a8000201000000 (NOP, EOOL, 2 pad): 24 -> 22 octets, IHL still 6.

Repro: /tmp/rtissues/corekit-repro.py (check D3) on origin/main 11ae68e.

Expected behavior
The padding length is carried through to_dict()/from_dict() so the rebuilt header matches its own length field.

Found by the corekit round-trip audit (#1202). The repro was re-checked by an independent verifier, and I re-ran it on main at 11ae68ebf.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  2. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Blocked until the core schema PR for #1274/#1275/#1265/#1285 merges, because both edit protocols/schema/schema.py.

  3. added
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  4. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1331 merged at 20:41Z. Back to pending.

  5. added
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    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
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  6. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 8, 2026
  7. added this to the PyPCAPKit v1.5 milestone on Oct 25, 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