]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: htx: Defrag if blocks position is changed and the payloads wrap
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 11 Apr 2019 11:43:57 +0000 (13:43 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Apr 2019 19:34:30 +0000 (21:34 +0200)
When a header is added or when a data block is added before another one, the
blocks position may be changed (but not their payloads position). For instance,
when a header is added, we move the block just before the EOH, if any. When the
payloads wraps, it is pretty annoying because we loose the last inserted
block. It is neither the tail nor the head. And it is not the front either.

It is a design problem. Waiting for fixing this problem, we force a
defragmentation in such case. Anyway, it should be pretty rare, so it's not
really critical.

This patch must be backported to 1.9.

src/http_htx.c
src/htx.c

index a8c87b7663e426b56d4f2e5412440289a0db1008..21a5b57f416a3684962b4aa2a8d30f7aef3c288f 100644 (file)
@@ -183,6 +183,10 @@ int http_add_header(struct htx *htx, const struct ist n, const struct ist v)
 
                blk = pblk;
        }
+
+       if (htx_get_blk_pos(htx, blk) != htx->front)
+               htx_defrag(htx, NULL);
+
        return 1;
 }
 
index de879260a78d03ec95cb7d3a3970ee8a9f8b92b8..24e387eed7681044891385bf8b1046e94d118686 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -841,6 +841,10 @@ struct htx_blk *htx_add_data_before(struct htx *htx, const struct htx_blk *ref,
                        break;
                blk = pblk;
        }
+
+       if (htx_get_blk_pos(htx, blk) != htx->front)
+               htx_defrag(htx, NULL);
+
        return blk;
 }