BUG/MEDIUM: cache: Properly copy headers splitted on several shctx blocks
In the cache, huge HTTP headers will use several shctx blocks. When a response
is returned from the cache, these headers must be properly copied in the
corresponding HTX message by updating the pointer where to copied a header
part.
This patch must be backported to 2.0 and 1.9.
diff --git a/src/cache.c b/src/cache.c
index 0015326..242d7da 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -716,6 +716,7 @@
struct cache_flt_conf *cconf = appctx->rule->arg.act.p[0];
struct shared_context *shctx = shctx_ptr(cconf->c.cache);
struct htx_blk *blk;
+ char *ptr;
unsigned int max, total;
uint32_t blksz;
@@ -734,12 +735,14 @@
blk->info = info;
total = 4;
+ ptr = htx_get_blk_ptr(htx, blk);
while (blksz) {
max = MIN(blksz, shctx->block_size - offset);
- memcpy(htx_get_blk_ptr(htx, blk), (const char *)shblk->data + offset, max);
+ memcpy(ptr, (const char *)shblk->data + offset, max);
offset += max;
blksz -= max;
total += max;
+ ptr += max;
if (blksz || offset == shctx->block_size) {
shblk = LIST_NEXT(&shblk->list, typeof(shblk), list);
offset = 0;