Skip to content

fix(engines): a Simple Packet Block keeps its padding when the interface snaplen is 0 #1558

Closed

Description

@JarryShaw

Describe the bug
When interface 0's snaplen is 0, the default engine includes a Simple Packet Block's padding in the packet data. A snaplen of 0 means no limit.

Reproduction
Use a PCAP-NG with one SHB, one IDB (link type 1) and one SPB, where the SPB's original length is 57 and its data is 57 octets plus 3 octets of padding.

Expected behavior
57 octets in both cases. The packet is min(original_len, snaplen) octets, with 0 meaning no limit. See the PCAP-NG spec on the Simple Packet Block.

System information
Linux, CPython 3.14.7, main at 16fbea054.

Additional context
pcapkit/protocols/misc/pcapng.py:1201-1206 already skips a zero snaplen (if interfaces and interfaces[0].snaplen:). However, the engine passes 'snaplen': self._get_snaplen() in __packet__ (pcapkit/foundation/engines/pcapng.py:204-209). That passes the 0 straight through, and the setdefault then never applies.

Found by the #1550 review. This is blocked until #1523 merges, because #1523 edits both files.

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. JarryShaw commented on Oct 10, 2026

    @JarryShaw
    OwnerAuthor

    Unblocking early to meet a deadline. A worker started from main (a3da376dd) on #1502, #1504 and #1558 together, since all three need pcapkit/protocols/misc/pcapng.py. It will rebase over #1523 when that merges, keeping every #1523 hunk.

  3. 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
  4. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 10, 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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions