Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/mqtt_sn_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,15 @@ int SN_Decode_GWInfo(byte *rx_buf, int rx_buf_len, SN_GwInfo *gw_info)
if (total_len > rx_buf_len) {
return MQTT_TRACE_ERROR(MQTT_CODE_ERROR_OUT_OF_BUFFER);
}
if (total_len < 3) {
/* Reject a frame whose total_len cannot cover the bytes still to be read
* after the length-indicator block (message type + gateway ID). The
* short-form header consumes one byte and the extended-length form
* consumes three, so the prior fixed "< 3" minimum was only valid for
* the short form: an extended-length GWINFO with total_len <= the
* header bytes already consumed would slip past it and the
* *rx_payload++ reads below would walk past the caller-supplied
* buffer. */
if (total_len < (word16)(rx_payload - rx_buf) + 2) {
return MQTT_TRACE_ERROR(MQTT_CODE_ERROR_MALFORMED_DATA);
}
/* Check message type */
Expand Down
Loading