Read the 16-bit extended option delta/length correctly


RFC 7252 section 3.1 encodes an option delta or length of 13 as an 8-bit
integer (value minus 13) and 14 as a 16-bit integer in network byte
order (value minus 269). createFromFrame() read only a single byte for
the 14 case and advanced the cursor by one instead of two. The decoded
value was therefore wrong, and the second extended byte was
reinterpreted as the next option's header, so the remainder of the frame
was misparsed.

Read both bytes in network byte order (with qFromBigEndian), advance
the cursor by two, and bounds-check both. The extended range reaches
65804, which does not fit in the quint16 previously used for the delta,
length, and option number, so widen those to quint32. A cumulative option
number above 65535 is not a valid CoAP option number and would leave
every following option in the reply out of range as well, so reject such
a frame instead of storing it as an unknown option.

[ChangeLog][QtCoap] Fixed the decoding of options that use the 16-bit
extended delta or length encoding. Such an option was
previously read as a single byte, producing an incorrect value and
causing the remainder of the message to be misparsed.

Task-number: QTBUG-149345
Pick-to: 6.12 6.11 6.8
Change-Id: I2c1bf1ac04a54a33a99a26643be0b0aca0860c98
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
commit573035207dbe963b6a73ba58e9b581c299bac73c
parent9f60c7438ebd48a5422f32f09570569e0fed9418
authorMate Barany <mate.barany@qt.io>
committerMate Barany <mate.barany@qt.io>
commit timeTue, 1 Sep 2026 14:38:35 +0000