fuzzer rx overflow mitigate

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-01-20 09:19:17 +08:00
parent 00e5eb8658
commit ffd361430c
4 changed files with 7 additions and 0 deletions

View file

@ -751,6 +751,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,

View file

@ -885,6 +885,10 @@ handle_first:
return 1;
}
if (wsi->u.ws.rx_user_buffer_head + LWS_SEND_BUFFER_PRE_PADDING >= 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

@ -818,6 +818,7 @@ struct _lws_websocket_related {
unsigned int rx_user_buffer_head;
unsigned char mask_nonce[4];
unsigned char frame_mask_index;
unsigned int rx_ubuf_alloc;
size_t rx_packet_length;
unsigned char opcode;
unsigned int final:1;

View file

@ -566,6 +566,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 LWS_POSIX
if (setsockopt(wsi->sock, SOL_SOCKET, SO_SNDBUF,