From 4cee34c0d06a6f43baf22260ba906283fce5e3d4 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 29 Dec 2017 02:41:05 +0800 Subject: [PATCH] h2: adapt oversize POST test now we handle blocks in parser not byte-at-a-time --- lib/http2/http2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/http2/http2.c b/lib/http2/http2.c index e5e5e4a8..90e821f8 100644 --- a/lib/http2/http2.c +++ b/lib/http2/http2.c @@ -1478,7 +1478,7 @@ lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t inlen, if (lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_CONTENT_LENGTH) && h2n->swsi->http.rx_content_length && - h2n->swsi->http.rx_content_remain == 1 && /* last */ + h2n->swsi->http.rx_content_remain < inlen + 1 && /* last */ h2n->inside < h2n->length) { /* unread data in frame */ lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, "More rx than content_length told"); @@ -1488,7 +1488,11 @@ lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t inlen, h2n->swsi->outer_will_close = 1; n = lws_read(h2n->swsi, in - 1, inlen + 1); h2n->swsi->outer_will_close = 0; - if (n < 0) + /* + * can return 0 in POST body with content len + * exhausted somehow. + */ + if (n <= 0) goto fail; inlen -= n - 1;