From 914bac185be82adaec74758e37a7e6de4302153b Mon Sep 17 00:00:00 2001 From: NK Date: Fri, 4 Sep 2026 23:34:22 +0530 Subject: [PATCH] zigbee: fix ZCLPricePublishPrice rate_label dissection 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. Per review, replace it with the standard pair: a FieldLenField carrying the length octet and a StrLenField sized from it through length_from. AI-Assisted: yes (Claude) --- scapy/layers/zigbee.py | 9 +++++---- test/scapy/layers/dot15d4.uts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scapy/layers/zigbee.py b/scapy/layers/zigbee.py index 8531ca6f79d..f57986c1e7c 100644 --- a/scapy/layers/zigbee.py +++ b/scapy/layers/zigbee.py @@ -14,9 +14,9 @@ from scapy.packet import bind_layers, bind_bottom_up, Packet from scapy.fields import BitField, ByteField, XLEIntField, ConditionalField, \ - ByteEnumField, EnumField, BitEnumField, FieldListField, FlagsField, \ - IntField, PacketListField, ShortField, StrField, StrFixedLenField, \ - StrLenField, XLEShortField, XStrField + ByteEnumField, EnumField, BitEnumField, FieldLenField, FieldListField, \ + FlagsField, IntField, PacketListField, ShortField, StrField, \ + StrFixedLenField, StrLenField, XLEShortField, XStrField from scapy.layers.dot15d4 import dot15d4AddressField, Dot15d4Beacon, Dot15d4, \ Dot15d4FCS @@ -1323,7 +1323,8 @@ class ZCLPricePublishPrice(Packet): fields_desc = [ XLEIntField("provider_id", 0x00000000), # Unsigned 32-bit Integer (4 octets) # noqa: E501 # Rate Label is a UTF-8 encoded Octet String (0-12 octets). The first Octet indicates the length. # noqa: E501 - StrLenField("rate_label", "", length_from=lambda pkt:int(pkt.rate_label[0])), # TODO verify # noqa: E501 + FieldLenField("rate_label_len", None, length_of="rate_label", fmt="