fuzzer rx overflow mitigate

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-01-20 08:40:14 +08:00
parent ab620ffde3
commit 26ba55a6fc
4 changed files with 7 additions and 0 deletions

View file

@ -767,6 +767,7 @@ check_accept:
lwsl_err("Out of Mem allocating rx buffer %d\n", n);
goto bail2;
}
wsi->u.ws.rx_ubuf_alloc = n;
lwsl_info("Allocating client RX buffer %d\n", n);
if (setsockopt(wsi->sock, SOL_SOCKET, SO_SNDBUF, (const char *)&n, sizeof n)) {

View file

@ -820,6 +820,10 @@ handle_first:
return 1;
}
if (wsi->u.ws.rx_ubuf_head + LWS_PRE >= wsi->u.ws.rx_ubuf_alloc) {
lwsl_err("Attempted overflow\n");
return -1;
}
if (wsi->u.ws.all_zero_nonce)
wsi->u.ws.rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING +
(wsi->u.ws.rx_user_buffer_head++)] = c;

View file

@ -776,6 +776,7 @@ struct _lws_header_related {
struct _lws_websocket_related {
char *rx_user_buffer;
int rx_user_buffer_head;
unsigned int rx_ubuf_alloc;
unsigned char frame_masking_nonce_04[4];
unsigned char frame_mask_index;
size_t rx_packet_length;

View file

@ -561,6 +561,7 @@ upgrade_ws:
lwsl_err("Out of Mem allocating rx buffer %d\n", n);
return 1;
}
wsi->u.ws.rx_ubuf_alloc = n;
lwsl_info("Allocating RX buffer %d\n", n);
if (setsockopt(wsi->sock, SOL_SOCKET, SO_SNDBUF, (const char *)&n, sizeof n)) {