Skip to content

Commit 8440307

Browse files
1010101001010101jukkar
authored andcommitted
net/mqtt: Add payload size validation
Validate payload size before starting to decodify MQTT messages. Change-Id: I02653b5e41f930ca75de8f0395b2a7df315e12c5 Signed-off-by: Flavio Santes <[email protected]>
1 parent 9c8d2d9 commit 8440307

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

subsys/net/lib/mqtt/mqtt_pkt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ int mqtt_unpack_connect(uint8_t *buf, uint16_t length,
478478
return rc;
479479
}
480480

481+
/* header size + remaining length value + rm length size */
482+
if (PACKET_TYPE_SIZE + rlen + rlen_size > length) {
483+
return -EINVAL;
484+
}
485+
481486
/* offset points to the protocol name length */
482487
offset = PACKET_TYPE_SIZE + rlen_size;
483488

0 commit comments

Comments
 (0)