]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: don't demand that a DATA frame is complete before processing it
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Dec 2017 17:36:37 +0000 (18:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 14 Dec 2017 12:43:52 +0000 (13:43 +0100)
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

index af2ee17d1f41096b3d35de8227b3a021908b8e61..672bc8ff360ad11244de4a61c4f5678e172535b1 100644 (file)
@@ -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);