QCoAp: Guard block-option parsing against a zero-length value


setFromDescriptiveBlockOption() and nextBlockToSend() both read the last
byte of a block option as optionData[option.length() - 1]. When the
option value is empty, length() is 0 and that expression is
optionData[-1]

Since an empty block option means NUM=0, M=0, SZX=0, substituting a
last byte of 0 both avoids the out-of-bounds read and yields the correct
result (block number 0, no further block, block size 16). Guard both
reads with a length check accordingly.

Task-number: QTBUG-149345
Pick-to: 6.12 6.11 6.8
Change-Id: I03c9a096e907722d7516295b942a1b4e8616af8c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
commit43f4b9fe4084b76c4f55e2f2591095684f1bc2d6
parent1a369fc74f05b22db37f4021eec382c8c1aad84f
authorMate Barany <mate.barany@qt.io>
committerMate Barany <mate.barany@qt.io>
commit timeTue, 1 Sep 2026 17:07:29 +0000