From 15a4ce870a19bdb6e6ed0a210d844178145de1b3 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 3 Sep 2019 22:11:52 +0200 Subject: [PATCH] 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. --- src/cache.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cache.c b/src/cache.c index 001532651..242d7daf0 100644 --- a/src/cache.c +++ b/src/cache.c @@ -716,6 +716,7 @@ static unsigned int htx_cache_dump_blk(struct appctx *appctx, struct htx *htx, e 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 @@ static unsigned int htx_cache_dump_blk(struct appctx *appctx, struct htx *htx, e 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;