]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: htx: Set the right start-line offset after a defrag
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Dec 2018 13:31:12 +0000 (14:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Dec 2018 14:01:40 +0000 (15:01 +0100)
The offset was always wrong after an HTX defragmentation because the wrong
address was used and because the update could occcur several time on the same
defragmentation.

src/htx.c

index 1f0ebebc919d3d27c3ec99ecb32e7fabc8ff499f..5ca7b7e6366eb4f8ebe30a0d38e17f0bef8bad6e 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -28,6 +28,7 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk)
        struct htx_blk *newblk, *oldblk;
        uint32_t new, old;
        uint32_t addr, blksz;
+       int32_t sl_off = -1;
 
        if (!htx->used)
                return NULL;
@@ -49,19 +50,20 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk)
                newblk->info = oldblk->info;
                blksz = htx_get_blksz(oldblk);
 
+               /* update the start-line offset */
+               if (htx->sl_off == oldblk->addr)
+                       sl_off = addr;
+
                memcpy((void *)tmp->blocks + addr, htx_get_blk_ptr(htx, oldblk), blksz);
                new++;
                addr += blksz;
 
-               /* update the start-line offset */
-               if (htx->sl_off == oldblk->addr)
-                       htx->sl_off = addr;
-
                /* if <blk> is defined, set its new location */
                if (blk != NULL && blk == oldblk)
                        blk = newblk;
        } while (new < htx->used);
 
+       htx->sl_off = sl_off;
        htx->wrap = htx->used;
        htx->front = htx->tail = new - 1;
        memcpy((void *)htx->blocks, (void *)tmp->blocks, htx->size);