mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-20 11:19:56 +00:00
mqtt: parse properties in MQTT 5.0 CONNACK packets
Under MQTT 5.0, decode the property length and set props_start and props_size for MQTT_CMD_CONNACK. Add unit test coverage.
This commit is contained in:
1 parent
8e0c765c2c
commit
1f2b14bb66
3 files changed
+27
No files matched your search
+10
@@ -438,6 +438,16 @@ int mg_mqtt_parse(const uint8_t *buf, size_t len, uint8_t version,
|
||||
case MQTT_CMD_CONNACK:
|
||||
if (end - p < 2) return MQTT_MALFORMED;
|
||||
m->ack = p[1];
|
||||
p += 2;
|
||||
if (version == 5) {
|
||||
if (p >= end) return MQTT_MALFORMED;
|
||||
len_len = (uint32_t) decode_varint(p, (size_t) (end - p), &tmp);
|
||||
if (!len_len) return MQTT_MALFORMED;
|
||||
m->props_size = (size_t) tmp;
|
||||
m->props_start = (size_t) (p + len_len - buf);
|
||||
p += len_len + m->props_size;
|
||||
if (p > end) return MQTT_MALFORMED;
|
||||
}
|
||||
break;
|
||||
case MQTT_CMD_PUBACK:
|
||||
case MQTT_CMD_PUBREC:
|
||||
|
||||
Reference in new issue
Block a user