Skip to content

fix(misc): let the built-in record a held ZigBee key's short read (#2688) - #2697

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2688-zigbee-key-short-read
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2688-zigbee-key-short-read

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

zigbee_key_held in the PCAP-NG schema module padded short Secrets Data to the key's width with ljust, then hand-wrote the __short_read__ record that Schema.unpack already makes. The padding also made the returned schema's bytes() the full key width. So a Decryption Secrets Block built from a parsed short-key model came out wrongly sized and unaligned, for every short count from 0 up to the key width.

It now unpacks the held octets as they are, with a declared length, and the built-in records the cut. The already-reported short-read warning is discarded through hold_warnings.

The new tests cut each NWK and APS key at every offset, at the schema level and through make and from_data. Each short count fails on main, and both tests assert that nothing is reported twice. Shipped captures parse identically to main.

Closes #2688

)

zigbee_key_held zero-filled the Secrets Data to the key's fixed width,
unpacked that, and wrote __short_read__ by hand, duplicating
Schema._note_short_read. Its buffers then spanned the fixed width until
packed, so a Decryption Secrets Block made from a parsed short key was
sized from them and written corrupt.

Unpack the octets as held, with a declared length so that empty Secrets
Data is not the end of the stream, and let Schema.unpack record the cut.
The parse already reported the short read, so its warnings are dropped
through hold_warnings with discard set.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) 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 983a5c6df, from a Sonnet cross-review.

  • The built-in now does the work. Its record matches the old hand-written one at every count.
  • The corrupt-block bug is fixed. On base, 40 of 48 rebuilt blocks were corrupt (exactly the short counts); on this head none are.
  • The discard drops only the duplicate. It suppresses only the short-read warning the parse already reported, through the library's own hold_warnings.
  • The tests catch regressions. Each mutation of the declared length or the discard fails them.
  • Captures are unchanged. Shipped captures are identical to main.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 2, 2026
@JarryShaw
JarryShaw merged commit 6dd3f87 into main Nov 2, 2026
63 checks passed
@JarryShaw
JarryShaw deleted the fix/2688-zigbee-key-short-read branch November 2, 2026 22:44
@github-project-automation github-project-automation Bot moved this from In review 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
…s, the cut schema lists, the TSO checksum cut and short ZigBee keys into 1.6.0 (#2449)

- Breaking: MH (#2700) refuses a mobility option, or a sub-option, QoS
  attribute or CGA extension of one, whose fields do not take its length,
  where 1.5.x rebuilt another; QualityOfServiceOption gains a required
  tc_reserved. Prefix lengths are held to their field's width, the NAI and
  service identifier makers count octets, and a long-form DER CGA key
  parses. Folded into the MH/DSS and makers' range-check entries, with a
  QoS entry of its own; old and new values measured against v1.5.1.
- Fixed: ListField zero-fills a cut list of schema items, bounded by
  ZERO_PAD_BUDGET_RATIO with no free band, and a SACK past the data raises
  ProtocolError where it raised FieldValueError (#2701); a Decryption
  Secrets Block made from a short parsed ZigBee key is written as captured,
  and zigbee_key_held's schema holds the octets given (#2697).
- Folded into unreleased entries: radiotap's mixed bitmaps, their
  known-bits registries and BitmapField (#2696), into the Radiotap entry;
  the TSO and AH checksum cut (#2699), into the checksum and contextvars
  entries; the zero-filled SETTINGS and IGMPv3 records and the IGMPv3
  Additional Data rebuild (#2701), into the HTTP/2 SETTINGS and IGMP
  entries, dropping HTTPv2.make's unreleased frame_length.
- No entry for the docstring-and-test-only be83061 (#2695).
- 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

bug Issues reporting a defect (set by the bug report template; a default, not an assessment)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(misc): PCAP-NG ZigBee keys hand-roll a short-read record

1 participant