From d899f230174d768dce0b482d7cfd6522d79c8634 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 13 Apr 2026 19:07:08 +0200 Subject: [PATCH] BUG/MEDIUM: htx: Properly handle block modification during defragmentation A regression was introcuded by the commit 0c6f2207f ("MEDIUM: htx: Refactor htx defragmentation to merge data blocks"). When a defragmentation is performed, it is possible to alter a block size. The main usage is to prepare a block value replacement. However, since the commit above, the change is no longer handled. The block info are changed but the size of the message is not modified accordingly. This patch depends on the commit "MINOR: htx: Add helper function to get type and size from the block info field" No backport needed. --- src/htx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/htx.c b/src/htx.c index e5cbc80dc..6ace1d3e8 100644 --- a/src/htx.c +++ b/src/htx.c @@ -72,8 +72,14 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t blkinf } __fallthrough; default: - newblk = htx_add_blk(tmp, type, blksz); - newblk->info = oldblk->info; + if (blk == oldblk && blkinfo) { + newblk = htx_add_blk(tmp, type, __htx_blkinfo_size(blkinfo)); + newblk->info = blkinfo; + } + else { + newblk = htx_add_blk(tmp, type, blksz); + newblk->info = oldblk->info; + } htx_memcpy(htx_get_blk_ptr(tmp, newblk), htx_get_blk_ptr(htx, oldblk), blksz); break; }; @@ -83,15 +89,13 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t blkinf tmp->first = new; /* if is defined, save its new position */ - if (blk != NULL && blk == oldblk) { - if (blkinfo) - newblk->info = blkinfo; + if (blk == oldblk) blkpos = new; - } + new++; } - BUG_ON(htx->data != tmp->data); + htx->data = tmp->data; htx->first = tmp->first; htx->head = tmp->head; htx->tail = tmp->tail;