From owner-svn-src-stable-11@freebsd.org Wed Sep 13 21:21:34 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A89FFE10341; Wed, 13 Sep 2017 21:21:34 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 83E2277270; Wed, 13 Sep 2017 21:21:34 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8DLLXm4026215; Wed, 13 Sep 2017 21:21:33 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8DLLXs7026213; Wed, 13 Sep 2017 21:21:33 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201709132121.v8DLLXs7026213@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Wed, 13 Sep 2017 21:21:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323563 - stable/11/contrib/zlib X-SVN-Group: stable-11 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/11/contrib/zlib X-SVN-Commit-Revision: 323563 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Sep 2017 21:21:34 -0000 Author: marius Date: Wed Sep 13 21:21:33 2017 New Revision: 323563 URL: https://svnweb.freebsd.org/changeset/base/323563 Log: MFC: 323382, MFV: r323381 Permit a deflateParams() parameter change as soon as possible. This change fixes compression errors seen when the embedded Tomcat web server of a UniFi Controller zlib compresses responses. Given that Tomcat just uses Java/OpenJDK which in turn employs zlib for its compression/decompression support, this bug might very well affect other applications, too. PR: 222136 Modified: stable/11/contrib/zlib/deflate.c stable/11/contrib/zlib/zlib.h Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/zlib/deflate.c ============================================================================== --- stable/11/contrib/zlib/deflate.c Wed Sep 13 19:30:09 2017 (r323562) +++ stable/11/contrib/zlib/deflate.c Wed Sep 13 21:21:33 2017 (r323563) @@ -494,7 +494,7 @@ int ZEXPORT deflateResetKeep (strm) s->wrap == 2 ? crc32(0L, Z_NULL, 0) : #endif adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; + s->last_flush = -2; _tr_init(s); @@ -587,12 +587,12 @@ int ZEXPORT deflateParams(strm, level, strategy) func = configuration_table[s->level].func; if ((strategy != s->strategy || func != configuration_table[level].func) && - s->high_water) { + s->last_flush != -2) { /* Flush the last buffer: */ int err = deflate(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) return err; - if (strm->avail_out == 0) + if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) return Z_BUF_ERROR; } if (s->level != level) { Modified: stable/11/contrib/zlib/zlib.h ============================================================================== --- stable/11/contrib/zlib/zlib.h Wed Sep 13 19:30:09 2017 (r323562) +++ stable/11/contrib/zlib/zlib.h Wed Sep 13 21:21:33 2017 (r323563) @@ -712,11 +712,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the - strategy is changed, and if any input has been consumed in a previous - deflate() call, then the input available so far is compressed with the old - level and strategy using deflate(strm, Z_BLOCK). There are three approaches - for the compression levels 0, 1..3, and 4..9 respectively. The new level - and strategy will take effect at the next call of deflate(). + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1..3, and 4..9 + respectively. The new level and strategy will take effect at the next call + of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not