From owner-svn-src-stable-8@FreeBSD.ORG Sat Dec 5 18:59:59 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13ABD1065672; Sat, 5 Dec 2009 18:59:59 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCD268FC13; Sat, 5 Dec 2009 18:59:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nB5IxwX7096240; Sat, 5 Dec 2009 18:59:58 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nB5IxwRD096238; Sat, 5 Dec 2009 18:59:58 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200912051859.nB5IxwRD096238@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sat, 5 Dec 2009 18:59:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200139 - stable/8/sys/opencrypto X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Dec 2009 18:59:59 -0000 Author: bz Date: Sat Dec 5 18:59:58 2009 New Revision: 200139 URL: http://svn.freebsd.org/changeset/base/200139 Log: MFC r199887: Z_PARTIAL_FLUSH is marked deprecated. Z_SYNC_FLUSH is the suggested replacement but only use it for inflate. For deflate use Z_FINISH as Z_SYNC_FLUSH adds a trailing marker in some cases that inflate(), despite the comment in zlib, does npt seem to cope well with, resulting in errors when uncompressing exactly fills the outbut buffer without a Z_STREAM_END and a successive call returns an error. Modified: stable/8/sys/opencrypto/deflate.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/opencrypto/deflate.c ============================================================================== --- stable/8/sys/opencrypto/deflate.c Sat Dec 5 18:57:32 2009 (r200138) +++ stable/8/sys/opencrypto/deflate.c Sat Dec 5 18:59:58 2009 (r200139) @@ -138,8 +138,8 @@ deflate_global(data, size, decomp, out) goto bad; } for (;;) { - error = decomp ? inflate(&zbuf, Z_PARTIAL_FLUSH) : - deflate(&zbuf, Z_PARTIAL_FLUSH); + error = decomp ? inflate(&zbuf, Z_SYNC_FLUSH) : + deflate(&zbuf, Z_FINISH); if (error != Z_OK && error != Z_STREAM_END) { /* * Unfortunately we are limited to 5 arguments, @@ -153,9 +153,13 @@ deflate_global(data, size, decomp, out) zbuf.state->dummy, zbuf.total_out); goto bad; } - else if (zbuf.avail_in == 0 && zbuf.avail_out != 0) - goto end; - else if (zbuf.avail_out == 0 && i < (ZBUF - 1)) { + if (decomp && zbuf.avail_in == 0 && error == Z_STREAM_END) { + /* Done. */ + break; + } else if (!decomp && error == Z_STREAM_END) { + /* Done. */ + break; + } else if (zbuf.avail_out == 0) { /* we need more output space, allocate size */ buf[i].out = malloc((u_long) size, M_CRYPTO_DATA, M_NOWAIT); @@ -170,6 +174,7 @@ deflate_global(data, size, decomp, out) zbuf.avail_out = buf[i].size; i++; } else { + /* Unexpect result. */ /* * Unfortunately we are limited to 5 arguments, * thus, again, use two probes. @@ -184,7 +189,6 @@ deflate_global(data, size, decomp, out) } } -end: result = count = zbuf.total_out; *out = malloc((u_long) result, M_CRYPTO_DATA, M_NOWAIT);