From: Willy Tarreau Date: Sun, 28 Apr 2013 06:52:52 +0000 (+0200) Subject: BUG/MEDIUM: compression: the deflate algorithm must use global settings as well X-Git-Tag: v1.5-dev19~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5599e7c498ea51a11fa939026c9249012eaa19c;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: compression: the deflate algorithm must use global settings as well Global compression settings (windowsize and memlevel) were only considered for the gzip algorithm but not the deflate algorithm. Since a single allocator is used for both algos, if gzip was first initialized the memory with parameters smaller than default, then initializing deflate after with default settings would result in overusing the small allocated areas. To fix this, we make use of deflateInit2() for deflate_init() as well. Thanks to Godbach for reporting this bug, introduced by in 1.5-dev13 by commit 8b52bb38. No backport is needed. --- diff --git a/src/compression.c b/src/compression.c index 906e4fdd75..c8e914400d 100644 --- a/src/compression.c +++ b/src/compression.c @@ -513,7 +513,7 @@ int deflate_init(struct comp_ctx **comp_ctx, int level) strm = &(*comp_ctx)->strm; - if (deflateInit(strm, level) != Z_OK) { + if (deflateInit2(strm, level, Z_DEFLATED, global.tune.zlibwindowsize, global.tune.zlibmemlevel, Z_DEFAULT_STRATEGY) != Z_OK) { deinit_comp_ctx(comp_ctx); return -1; }