From: Christopher Faulet Date: Thu, 16 May 2019 09:30:31 +0000 (+0200) Subject: MINOR: htx: Be sure to xfer all headers in one time in htx_xfer_blks() X-Git-Tag: v2.0-dev5~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a61e97bcaeaa9128b27eb31c56850add036290fe;p=thirdparty%2Fhaproxy.git MINOR: htx: Be sure to xfer all headers in one time in htx_xfer_blks() 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. --- diff --git a/src/htx.c b/src/htx.c index bc2ecbdf3d..a7623b6d93 100644 --- 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 is empty, we report a parsing error + * on . + */ + 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; diff --git a/src/mux_h2.c b/src/mux_h2.c index ddaa751804..55c7619c51 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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);