From: Ilya Leoshkevich Date: Wed, 19 Apr 2023 14:03:18 +0000 (+0200) Subject: IBM zSystems: Fix calling deflateBound() before deflateInit() X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2.0.x;p=thirdparty%2Fzlib-ng.git IBM zSystems: Fix calling deflateBound() before deflateInit() Even though zlib officialy forbids calling deflateBound() before deflateInit(), Firefox does this anyway, and it happens to work [1], but unfortunately not with DFLTCC [2], because the DFLTCC code assumes that the deflate state is allocated, and segfaults when it isn't. Bow down before Hyrum's Law and add deflateStateCheck() to DEFLATE_BOUND_ADJUST_COMPLEN(). [1] https://searchfox.org/mozilla-esr102/source/dom/script/ScriptCompression.cpp#97 [2] https://bugzilla.suse.com/show_bug.cgi?id=1210593 --- diff --git a/arch/s390/dfltcc_deflate.h b/arch/s390/dfltcc_deflate.h index 218e5946..1081b274 100644 --- a/arch/s390/dfltcc_deflate.h +++ b/arch/s390/dfltcc_deflate.h @@ -40,7 +40,7 @@ int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned cha #define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, source_len) \ do { \ - if (dfltcc_can_deflate((strm))) \ + if (deflateStateCheck((strm)) || dfltcc_can_deflate((strm))) \ (complen) = DEFLATE_BOUND_COMPLEN(source_len); \ } while (0)