mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-24 19:19:00 +08:00
Harden MQTT variable length parsing
PUBLISHED_FROM=e16ee57bc30277e5b5684e53da78e69baaf9f779
This commit is contained in:
parent
abf89d32d9
commit
77e44c7c0e
@ -9943,11 +9943,12 @@ MG_INTERNAL int parse_mqtt(struct mbuf *io, struct mg_mqtt_message *mm) {
|
|||||||
lc = *((const unsigned char *) p++);
|
lc = *((const unsigned char *) p++);
|
||||||
len += (lc & 0x7f) << 7 * len_len;
|
len += (lc & 0x7f) << 7 * len_len;
|
||||||
len_len++;
|
len_len++;
|
||||||
if (!(lc & 0x80) || (len_len > sizeof(len))) break;
|
if (!(lc & 0x80)) break;
|
||||||
|
if (len_len > 4) return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
end = p + len;
|
end = p + len;
|
||||||
if (lc & 0x80 || end > io->buf + io->len) {
|
if (lc & 0x80 || len > (io->len - (p - io->buf))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user