Reject CoAP frames shorter than the fixed header


QCoapInternalReply::createFromFrame() dereferenced the first four header
bytes (version/type/token length, response code and message ID) without
first checking the frame length. A UDP datagram shorter than the 4-byte
CoAP header therefore caused an out-of-bounds read while populating the
header fields.

Reject frames shorter than 4 bytes in createFromFrame() by returning
nullptr, and handle that in the callers: decode() propagates the
nullptr, and onFrameReceived() drops the datagram.

Task-number: QTBUG-149345
Pick-to: 6.12 6.11 6.8 6.5 5.15
Change-Id: Id4183e074bd2b32e96553e60461ac62aab4bbdf5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
commit86dd4196b7324535dc7cc35e86de78e429c41470
parent795e497d3015dfe2da45650fc039099d56a966f1
authorMate Barany <mate.barany@qt.io>
committerMate Barany <mate.barany@qt.io>
commit timeWed, 26 Aug 2026 22:02:28 +0000