# HG changeset patch # User Matthew Wild # Date 1779712168 -3600 # Node ID 721823e085ecb7c8d8b477c48a9e408ff85f6ff6 # Parent 604bed81808ee86b6092dffd31e161726d06a9fd net.stun: Fix parsing of STUN packets with 0-length attributes Not sure where the '20' came from. RFC 8489 defines attributes as simple TLVs, with the type+length header being always 16 bits (4 bytes). The branch for non-zero lengths already uses the correct header size. diff -r 604bed81808e -r 721823e085ec net/stun.lua --- a/net/stun.lua Mon May 25 13:23:03 2026 +0100 +++ b/net/stun.lua Mon May 25 13:29:28 2026 +0100 @@ -185,7 +185,7 @@ local attr_type, attr_len = struct.unpack(">I2I2", attr_hdr); --luacheck: ignore 211/attr_type if attr_len == 0 then table.insert(self.attributes, attr_hdr); - pos = pos + 20; + pos = pos + 4; else local data = bytes:sub(pos + 4, pos + 3 + attr_len); assert(#data == attr_len, "packet truncated in attribute value");