From: Mark Adler Date: Sat, 4 Apr 2026 01:16:25 +0000 (-0700) Subject: Make deflateBound() more conservative and handle negative wrap. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3bea50d76a2f914cd27876684435dee435f79ee2;p=thirdparty%2Fzlib-ng.git Make deflateBound() more conservative and handle negative wrap. Use GZIP_WRAPLEN instead of 6 when parameters are unavailable, and handle negative s->wrap values in the switch. Upstream: https://github.com/madler/zlib/commit/a8c321be --- diff --git a/deflate.c b/deflate.c index 043c35fbf..347123806 100644 --- a/deflate.c +++ b/deflate.c @@ -698,13 +698,13 @@ unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long complen = sourceLen + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, sourceLen); /* hook for IBM Z DFLTCC */ - /* if can't get parameters, return conservative bound plus zlib wrapper */ + /* if can't get parameters, return conservative bound plus a wrapper */ if (deflateStateCheck(strm)) - return complen + 6; + return complen + GZIP_WRAPLEN; /* compute wrapper length */ s = strm->state; - switch (s->wrap) { + switch (ABS(s->wrap)) { case 0: /* raw deflate */ wraplen = 0; break;