From 6847262211dd415140201ed312137055135f79cc Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 11 Dec 2017 18:36:37 +0100 Subject: [PATCH] MINOR: h2: don't demand that a DATA frame is complete before processing it Since last commit it's not required that the DATA frames are complete anymore so better start with what we have. Only the HEADERS frame requires this. This may be backported as part of the upload fixes. --- src/mux_h2.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index af2ee17d1..672bc8ff3 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2489,8 +2489,7 @@ static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode) /* Decode the payload of a HEADERS frame and produce the equivalent HTTP/1 * request. Returns the number of bytes emitted if > 0, or 0 if it couldn't * proceed. Stream errors are reported in h2s->errcode and connection errors - * in h2c->errcode. The caller must already have checked the frame header and - * ensured that the frame was complete or the buffer full. + * in h2c->errcode. */ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count) { @@ -2509,6 +2508,9 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count) return 0; } + if (h2c->dbuf->i < h2c->dfl && h2c->dbuf->i < h2c->dbuf->size) + return 0; // incomplete input frame + /* if the input buffer wraps, take a temporary copy of it (rare) */ wrap = h2c->dbuf->data + h2c->dbuf->size - h2c->dbuf->p; if (wrap < h2c->dfl) { @@ -2755,9 +2757,6 @@ static int h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, int count) if (!h2c->dbuf->size) return 0; // empty buffer - if (h2c->dbuf->i < h2c->dfl && h2c->dbuf->i < h2c->dbuf->size) - return 0; // incomplete input frame - switch (h2c->dft) { case H2_FT_HEADERS: ret = h2_frt_decode_headers(h2s, buf, count);