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>