Reject CoAP frames with a reserved or truncated token length
RFC 7252 §3 reserves token lengths 9-15 and requires treating them as
a message format error but the parser accepted them and mis-parsed the
frame. With a large reserved value the bytes that follow are swallowed
as the token and the remainder is parsed as options from the wrong
offset.
A valid token length could likewise claim more bytes than were
actually sent, producing a silently truncated token.
Neither is a crash now that the option loop is bounds-checked, but the
token is the key used to match a reply to its request, so a mis-parsed
or truncated token is an integrity problem. Reject both: a token length
greater than 8, and a token whose bytes do not all fit in the frame.
Task-number: QTBUG-149345
Pick-to: 6.12 6.11 6.8
Change-Id: I301bed8aa9aa1e17faf43dd7aa6ad0d85fc83cd3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>