Mercurial > prosody-hg
diff net/stun.lua @ 14175:721823e085ec 13.0
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.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 25 May 2026 13:29:28 +0100 |
| parents | ba409c67353b |
| children |
line wrap: on
line diff
--- 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");
