interpret zero rx buffer size as default in http

Reported by pystub

https://github.com/warmcat/libwebsockets/pull/33#issuecomment-29578258

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-12-08 21:26:52 +08:00
parent 944a78dc58
commit ca15338545

View file

@ -74,8 +74,11 @@ http_postbody:
wsi->u.http.post_buffer[wsi->u.http.body_index++] = *buf++;
wsi->u.http.content_length_seen++;
if (wsi->u.http.body_index !=
wsi->protocol->rx_buffer_size &&
n = wsi->protocol->rx_buffer_size;
if (!n)
n = LWS_MAX_SOCKET_IO_BUF;
if (wsi->u.http.body_index != n &&
wsi->u.http.content_length_seen != wsi->u.http.content_length)
continue;
@ -231,7 +234,10 @@ http_postbody:
if (wsi->u.http.content_length > 0) {
wsi->u.http.body_index = 0;
wsi->u.http.post_buffer = malloc(wsi->protocol->rx_buffer_size);
n = wsi->protocol->rx_buffer_size;
if (!n)
n = LWS_MAX_SOCKET_IO_BUF;
wsi->u.http.post_buffer = malloc(n);
if (!wsi->u.http.post_buffer) {
lwsl_err("Unable to allocate post buffer\n");
n = -1;