mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-24 20:21:49 +00:00
WS frame len sanity check
This commit is contained in:
1 parent
6316609a5f
commit
f37e5ecc38
2 files changed
+6
No files matched your search
@@ -4547,6 +4547,9 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
|
|||||||
mg_ntohl(*(uint32_t *) &buf[6]);
|
mg_ntohl(*(uint32_t *) &buf[6]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Sanity check, and integer overflow protection for the boundary check below
|
||||||
|
// data_len should not be larger than 1 Gb
|
||||||
|
// if (msg->data_len > 1024 * 1024 * 1024) return 0;
|
||||||
if (msg->header_len + msg->data_len > len) return 0;
|
if (msg->header_len + msg->data_len > len) return 0;
|
||||||
if (mask_len > 0) {
|
if (mask_len > 0) {
|
||||||
uint8_t *p = buf + msg->header_len, *m = p - mask_len;
|
uint8_t *p = buf + msg->header_len, *m = p - mask_len;
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
|
|||||||
mg_ntohl(*(uint32_t *) &buf[6]);
|
mg_ntohl(*(uint32_t *) &buf[6]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Sanity check, and integer overflow protection for the boundary check below
|
||||||
|
// data_len should not be larger than 1 Gb
|
||||||
|
// if (msg->data_len > 1024 * 1024 * 1024) return 0;
|
||||||
if (msg->header_len + msg->data_len > len) return 0;
|
if (msg->header_len + msg->data_len > len) return 0;
|
||||||
if (mask_len > 0) {
|
if (mask_len > 0) {
|
||||||
uint8_t *p = buf + msg->header_len, *m = p - mask_len;
|
uint8_t *p = buf + msg->header_len, *m = p - mask_len;
|
||||||
|
|||||||
Reference in new issue
Block a user