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.
This commit is contained in:
Christopher Faulet 2026-04-13 19:07:08 +02:00
parent ebaa88a23a
commit d899f23017

View File

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