From: Christopher Faulet Date: Mon, 29 Jul 2019 08:50:28 +0000 (+0200) Subject: BUG/MINOR: htx: Fix free space addresses calculation during a block expansion X-Git-Tag: v2.1-dev2~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61ed7797f6440ee1102576365553650b1982a233;p=thirdparty%2Fhaproxy.git BUG/MINOR: htx: Fix free space addresses calculation during a block expansion When the payload of a block is shrinked or enlarged, addresses of the free spaces must be updated. There are many possible cases. One of them is buggy. When there is only one block in the HTX message and its payload is just before the tail room and it needs to be moved in the head room to be enlarged, addresses are not correctly updated. This bug may be hit by the compression filter. This patch must be backported to 2.0. --- diff --git a/src/htx.c b/src/htx.c index 93acbaaae5..d8f435d447 100644 --- a/src/htx.c +++ b/src/htx.c @@ -246,11 +246,13 @@ static int htx_prepare_blk_expansion(struct htx *htx, struct htx_blk *blk, int32 ret = 1; } else if ((sz + delta) < headroom) { + uint32_t oldaddr = blk->addr; + /* Move the block's payload into the headroom */ blk->addr = htx->head_addr; htx->tail_addr -= sz; htx->head_addr += sz + delta; - if (blk->addr == htx->end_addr) { + if (oldaddr == htx->end_addr) { if (htx->end_addr == htx->tail_addr) { htx->tail_addr = htx->head_addr; htx->head_addr = htx->end_addr = 0;