Skip to content

refactor(protocols): range-check link and SSLv2 makers with _make_uint - #2629

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2614-make-uint-link
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2614-make-uint-link

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — changes neither behaviour nor performance

Description of your pull request and other information

GRE, FRAD, Netlink and Loopback make(), and SSLv2's make/read guard, range-check their fields through ProtocolBase._make_uint and pack through _make_pack, replacing their inline checks. Valid input builds the same bytes as before: 5,743 cases, and all 23 regenerated captures are identical.

Per the owner's ruling on #2614 (2a), out-of-range input raises ProtocolError. FRAD flag bits given as floats used to leak a bare ValueError. SSLv2 three-octet padding=True/False used to pack 1/0, and non-int padding raised TypeError. Four SSLv2 messages and the FRAD flag/snap_pid messages now take the '{alias}: invalid {name}: {value!r}' form. The RFC-constants sweep exempts a width passed as bits=/size= to the shared helpers, and a planted constant is still caught. OSPF follows in the next #2614 commit, which adds alias=.

A Sonnet cross-review checked every site pair and the byte identity. Its findings, the sweep rule and two missing pins, are folded in.

Part of #2614

#2614)

- GRE, FRAD, Netlink, Loopback: make()'s inline unsigned-int checks go
  through ProtocolBase._make_uint; Netlink and Loopback pack with
  _make_pack. The byte-order checks stay inline.
- FRAD: a float flag bit such as cr=1.0 raises ProtocolError rather than
  a raw ValueError; the flag and snap_pid messages drop their suffix.
- SSLv2: padding, and session_id_hit in make() and read(), use
  _make_uint; a bool or non-int 3-octet padding raises ProtocolError.
  Messages read 'SSLv2: invalid <name>: <value>'; their pins follow.
- OSPF keeps its check: _make_uint reads self.alias, unset before read().
- The #1739 sweep skips the bits=/size= field width a value helper takes.

Byte-identical make() output on a 5743-case grid and the samples; tests pass.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at e557a07de. A Sonnet cross-review checked every site pair's width and name, and built a 30,261-case grid against main. The only byte differences are the intended SSLv2 padding=True/False refusals. It flagged one blocking issue, now fixed: the RFC-constants sweep failed on the new bits= literals. A width passed to the shared helpers is now exempt, and a constant planted outside one is still caught. The SSLv2 read() int() and Loopback's byte-order message gained pins. This branch merges with the pending #2614 helpers commit cleanly, and on the merged tree the sweep and the member-order guard pass.

@JarryShaw
JarryShaw merged commit 2d6f18a into main Nov 2, 2026
14 checks passed
@JarryShaw
JarryShaw deleted the refactor/2614-make-uint-link branch November 2, 2026 04:52
@github-project-automation github-project-automation Bot moved this to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…types and the registry split into 1.6.0 (#2449)

- Breaking: Quick-Start values their fields cannot carry raise, reversing
  1.5.0's round-down of a TCP rate under 80 kbps (#2630).
- Folded into unreleased entries: tls12_cid records and DTLSContext
  (#2631), LinkType 105 and 127 in Frame and PCAP-NG (#2632), and
  DTLS.analyze_handshake behind dtls_handshake and packet (#2634).
- Changed: foundation.registry.protocols split into per-layer submodules
  (#2635); 1.6.0's register_* roles and 1.5.0's three register_protocol*
  roles point at their submodules, 1.5.0's text unchanged.
- The conventions entry records the per-layer wrapper placement (#2635)
  and parse ownership (#2634). No entry for #2629, which changes no
  released behaviour.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant