Check for int overflow when parsing WS frames

PUBLISHED_FROM=b7325b38e881455df703b0b628c41931565ccb33
This commit is contained in:
Deomid Ryabkov 2017-09-06 18:25:27 +01:00 committed by Cesanta Bot
parent f857f6394f
commit c8af7cdd27

View File

@ -9204,7 +9204,13 @@ static int mg_deliver_websocket_data(struct mg_connection *nc) {
}
frame_len = header_len + data_len;
ok = frame_len > 0 && frame_len <= buf_len;
ok = (frame_len > 0 && frame_len <= buf_len);
/* Check for overflow */
if (frame_len < header_len || frame_len < data_len) {
ok = 0;
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
if (ok) {
struct websocket_message wsm;