]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Be sure to xfer all headers in one time in htx_xfer_blks()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 16 May 2019 09:30:31 +0000 (11:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 May 2019 05:42:12 +0000 (07:42 +0200)
In the function htx_xfer_blks(), we take care to transfer all headers in one
time. When the current block is a start-line, we check if there is enough space
to transfer all headers too. If not, and if the destination is empty, a parsing
error is reported on the source.

The H2 multiplexer is the only one to use this function. When a parsing error is
reported during the transfer, the flag CS_FL_EOI is also set on the conn_stream.

src/htx.c
src/mux_h2.c

index bc2ecbdf3d6ed1ba41d58dd7b6c4548f6ef2ff12..a7623b6d93ce732f802d9da606ddfdff6d3cbf0d 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -502,6 +502,19 @@ struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count,
                if (type == HTX_BLK_UNUSED)
                        goto next;
 
+               /* Be sure to have enough space to xfer all headers in one
+                * time. If not while <dst> is empty, we report a parsing error
+                * on <src>.
+                */
+               if (mark >= HTX_BLK_EOH && (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL)) {
+                       struct htx_sl *sl = htx_get_blk_ptr(src, blk);
+
+                       if (sl->hdrs_bytes != -1 && sl->hdrs_bytes > count) {
+                               if (htx_is_empty(dst))
+                                       src->flags |= HTX_FL_PARSING_ERROR;
+                               break;
+                       }
+               }
 
                sz = htx_get_blksz(blk);
                info = blk->info;
index ddaa7518048d33af1ef289039ea32feb4de409b7..55c7619c51bff00551b9b3be0521a85ab7bb8c82 100644 (file)
@@ -5406,8 +5406,11 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
 
                htx_xfer_blks(buf_htx, h2s_htx, count, HTX_BLK_EOM);
 
-               if (h2s_htx->flags & HTX_FL_PARSING_ERROR)
+               if (h2s_htx->flags & HTX_FL_PARSING_ERROR) {
                        buf_htx->flags |= HTX_FL_PARSING_ERROR;
+                       if (htx_is_empty(buf_htx))
+                               cs->flags |= CS_FL_EOI;
+               }
 
                buf_htx->extra = (h2s_htx->extra ? (h2s_htx->data + h2s_htx->extra) : 0);
                htx_to_buf(buf_htx, buf);