Skip to content

fix(httpv2,ospf): make silently pads or truncates fixed-width inputs #1251

Closed

Description

@JarryShaw

Describe the bug
HTTP/2 PING data is BytesField(length=8) (pcapkit/protocols/schema/application/httpv2.py:388) and OSPF auth_data is BytesField(length=8) (pcapkit/protocols/schema/application/ospf.py:39). A shorter input is zero-padded and a longer one is cut, so the packet no longer matches what the caller passed and info is not what was given.

To Reproduce

  • bytes(HTTP(type=Frame.PING, sid=0, frame={'opaque_data': b'abc'}))[9:] == b'abc\0\0\0\0\0'; 10 octets b'0123456789' become b'01234567'.
  • bytes(OSPF(auth_data=b'abc'))[16:24] is abc plus five zero octets; 10 octets are cut to 8.

Expected behavior
A wrong-width input raises ProtocolError rather than being resized without notice.

Found by the application 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. moved this to Pending in PyPCAPKiton Oct 7, 2026
  3. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    A worker is on it now.

  4. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  5. moved this from Pending to WIP in PyPCAPKiton Oct 7, 2026
  6. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    The HTTP/2 PING half is fixed by #1341, which has merged. A worker is now checking whether the OSPF half still reproduces on main after #1304. It will fix it if it does, or close this issue with the measurement if it doesn't.

  7. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    I checked the OSPF half myself rather than dispatching a worker, and it is already fixed on main (36db4220a). OSPF(auth_data=b'abc') and OSPF(auth_data=b'0123456789') both raise ProtocolError: OSPF: authentication data must be 8 octets. The PING half was fixed by #1341, so both halves are done and I am closing this issue.

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