From 61ed7797f6440ee1102576365553650b1982a233 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 29 Jul 2019 10:50:28 +0200 Subject: [PATCH] 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. --- src/htx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/htx.c b/src/htx.c index 93acbaaae..d8f435d44 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;