Skip to content

Commit da93239

Browse files
committed
* FIX [mqtt_codec] Avoid UAF on properties decode error path
Signed-off-by: Moi Ran <maoyi.ran@emqx.io>
1 parent 316bcc9 commit da93239

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/supplemental/mqtt/mqtt_codec.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4051,16 +4051,21 @@ decode_buf_properties(uint8_t *packet, uint32_t packet_len, uint32_t *pos,
40514051
list = property_alloc();
40524052
/* Check properties appearance time */
40534053
// TODO
4054-
40554054
while (buf.curpos < buf.endpos) {
40564055
if (0 != read_byte(&buf, &prop_id)) {
40574056
property_free(list);
4058-
break;
4057+
list = NULL;
4058+
goto out;
40594059
}
40604060
property * cur_prop = NULL;
40614061
property_type_enum type = property_get_value_type(prop_id);
40624062
cur_prop =
40634063
property_parse(&buf, cur_prop, prop_id, type, copy_value);
4064+
if (cur_prop == NULL) {
4065+
property_free(list);
4066+
list = NULL;
4067+
goto out;
4068+
}
40644069
property_append(list, cur_prop);
40654070
}
40664071

0 commit comments

Comments
 (0)