Bound the byte count in QCoapOption::uintValue()


uintValue() decoded the option value by OR-ing each byte shifted left by
8*i. For a value longer than 4 bytes the shift count reached 32 or more,
which is undefined behaviour. The top-byte shift also operated on a
promoted signed int, which can overflow.

Stop the loop at 4 bytes and cast each byte to the result type before
shifting. Document that only the low 4 bytes are used and point callers
at length().

Task-number: QTBUG-149345
Pick-to: 6.12 6.11 6.8
Change-Id: I3eaab43cedbcf37d15491f882c86645673c2e047
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
commitff567721167650f0b9215f40875f3a8b8c87a8e7
parente029fbe562faa52ecd7dd5afdefcb2840582fa3f
authorMate Barany <mate.barany@qt.io>
committerMate Barany <mate.barany@qt.io>
commit timeTue, 1 Sep 2026 20:12:15 +0000