Mika Lindqvist [Sat, 21 Jan 2023 23:16:11 +0000 (01:16 +0200)]
Allow disabling visibility attribute with configure
* Disable visibility check for Cygwin, MinGW and MSYS as the compiler will only issue warning instead of error for unsupported attributes.
Fix ABI checking...
* Ubuntu 22.04 use different format for ABI files so old ones need to be removed
* Use more recent zlib-ng commit to avoid issues with internal adler32 and crc32 functions
Pavel P [Fri, 13 Jan 2023 18:31:48 +0000 (21:31 +0300)]
Fix compilation error where `crc32_fold` type matches field name in struct functable_s
If functable.h is included by a c++ compiler, compiler issues the following error (VS 2022):
```
zlib-ng/functable.h(20,49): error C2327: 'functable_s::crc32_fold': is not a type name, static, or enumerator
```
The error happens on line 20 because on previous line crc32_fold is declared as a struct member. Using `struct crc32_fold_s` instead of `crc32_fold` fixes the error.
Ilya Leoshkevich [Thu, 20 Oct 2022 00:28:47 +0000 (02:28 +0200)]
IBM zSystems DFLTCC: Support inflate with small window
There is no hardware control for DFLTCC window size, and because of
that supporting small windows for deflate is not trivial: one has to
make sure that DFLTCC does not emit large distances, which most likely
entails somehow trimming the window and/or input in order to make sure
that whave + avail_in <= wsize.
But inflate is much easier: one only has to allocate enough space. Do
that in dfltcc_alloc_window(), and also introduce ZCOPY_WINDOW() in
order to copy everything, not just what the software implementation
cares about.
After this change, software and hardware window formats no longer
match: the software will use wbits and wsize, and the hardware will use
HB_BITS and HB_SIZE. Unlike deflate, inflate does not switch between
software and hardware implementations mid-stream, which leaves only
inflateSetDictionary() and inflateGetDictionary() interesting.
Use CMake detection for Emscripten due to a bug in vcpkg.
When installing for wasm32 with vcpkg, CMake's try_run does not end up running
with the correct compiler. This issue has been mention in a few existing vcpkg
portfiles.
Alternatively, we could check the VCPKG_TARGET_ARCHITECTURE variable for wasm32
but instead we check for EMSCRIPTEN CMake variable.
This patch adds the ability to run zlib-ng test suite against the
original zlib as follows:
cmake -DZLIB_COMPAT=ON -DZLIBNG_ENABLE_TESTS=OFF .
make
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make test
The benefit of this is that modifications to the original zlib can be
tested with a more extensive zlib-ng's testsuite, and the assumptions
that the zlib-ng tests make can be validated against the original zlib.
In addition to a number of tests that exercise purely zlib-ng specific
API, there are a few that expect zlib-ng specific behavior from the
original zlib API:
- deflate() (obviously) emits different streams
- zlib-ng's deflatePrime() can take more than 16 bits
- zVersion() returns a different string
Adjust or disable the respective tests for ZLIBNG_ENABLE_TESTS=OFF.
Ilya Leoshkevich [Thu, 20 Oct 2022 04:28:44 +0000 (06:28 +0200)]
Fix deflate() with Z_BEST_COMPRESSION ignoring the dictionary
deflate_slow() uses s->quick_insert_string(), while
deflateSetDictionary() uses functable.insert_string(). These functions
use different hashing algorithms, which leads to deflate_slow()
ignoring the dictionary.
Fix by using s->insert_string() instead of functable.insert_string(),
which is set by lm_set_level() and matches what deflate_*() uses
(suggested by Mika Lindqvist).
Mika Lindqvist [Wed, 5 Oct 2022 10:58:28 +0000 (13:58 +0300)]
Fix memcpy() overflow in adler32_fold.c and crc32_fold.c
* On 32-bit platforms, last parameter of memcpy() is limited to SSIZE_MAX, but is likely to overlap if used
IBM Z DFLTCC: Fix updating strm.adler with inflate()
inflate() does not update strm.adler with DFLTCC.
Add a missing assignment to dfltcc_inflate() to fix this.
Note that deflate() is not affected.
Also add a test to prevent regressions.
Mika Lindqvist [Sun, 11 Sep 2022 13:15:10 +0000 (16:15 +0300)]
[Compat] Don't use uint32_t for z_crc_t
* We don't include stdint.h as it must be included before stdarg.h and other headers might include stdarg.h before us
Dougall Johnson [Mon, 22 Aug 2022 00:57:39 +0000 (10:57 +1000)]
Inflate: Increase max root table sizes to 10 and 9
This increases the size of the `codes` array by 1920 bytes (33%), but
improves performance a little. Root table size is still limited by the
maximum code length in use, so tiny files typically see no change to
table-building time, as they don't use longer codes.
Mika Lindqvist [Fri, 19 Aug 2022 12:00:21 +0000 (15:00 +0300)]
If the extra field was larger than the space the user provided with
inflateGetHeader(), and if multiple calls of inflate() delivered
the extra header data, then there could be a buffer overflow of the
provided space. This commit assures that provided space is not
exceeded.