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.
This commit is contained in:
Christopher Faulet 2019-07-29 10:50:28 +02:00
parent 301eff8e21
commit 61ed7797f6

View File

@ -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;