From: Christopher Faulet Date: Tue, 3 Sep 2019 20:11:52 +0000 (+0200) Subject: BUG/MEDIUM: cache: Properly copy headers splitted on several shctx blocks X-Git-Tag: v2.1-dev2~115 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15a4ce870a19bdb6e6ed0a210d844178145de1b3;p=thirdparty%2Fhaproxy.git 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 001532651d..242d7daf0b 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;