zigbee: fix ZCLPricePublishPrice rate_label dissection - #5148
Open
nkbeast wants to merge 4 commits into
Open
Conversation
added 4 commits
September 3, 2026 02:06
HSRP.guess_payload_class read self.underlayer.len unconditionally, so dissecting an HSRP packet that carries a trailing payload without an underlayer (e.g. HSRP(b'\x00\x01' + ...) or via layers that do not expose .len) raised AttributeError instead of dissecting the trailing bytes as the default payload class. Guard the underlayer access, keeping the HSRPmd5 selection unchanged when the underlayer is present and long enough. AI-Assisted: yes (Claude)
The six FieldListField entries were given the field classes (LEMACField, ByteField, ...) instead of instances, so any dissection of the event with num_response >= 1 raised 'Field.getfield() missing 1 required positional argument'. FieldListField expects an instance per its annotation (field: AnyField). Pass instances and cover a full inquiry result round trip in the test campaign. AI-Assisted: yes (Claude)
_InitialContextTokens[_parent.TOK_ID] raised KeyError for any TOK_ID outside the implemented set, aborting the dissection of a token with an attacker-supplied or future token identifier. Fall back to conf.raw_layer, consistent with the mysummary() fallback, keeping the body as raw bytes. Known TOK_IDs are unaffected. AI-Assisted: yes (Claude)
rate_label used a self-referential length callback, int(pkt.rate_label[0]), which reads the field before it is set, so dissecting the command always raised IndexError and the packet could never be parsed. The Rate Label is an octet string whose first octet carries its length; read that octet from the remaining buffer instead, keeping the length octet as part of the value (same convention as _DiscreteString in this module). AI-Assisted: yes (Claude)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ZCLPricePublishPrice.rate_labelused a self-referential length callback:length_fromreads the field's own value before it is set, sopkt.rate_labelis still the empty default and[0]raisesIndexErroron every dissection — the Publish Price command could never be parsed at all.Per the wire format noted in the comment ("The first Octet indicates the length"), the fix reads the length octet from the remaining buffer, following the
_DiscreteStringconvention of keeping the length tag inside the value:Round trip is byte-identical; a UTScapy test is included.