]> git.ipfire.org Git - thirdparty/zlib-ng.git/log
thirdparty/zlib-ng.git
2 years agoIBM zSystems: Fix calling deflateBound() before deflateInit() 2.0.x
Ilya Leoshkevich [Wed, 19 Apr 2023 14:03:18 +0000 (16:03 +0200)] 
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

2 years agoFix compilation on OpenBSD
Benjamin Stürz [Sun, 9 Apr 2023 16:02:04 +0000 (18:02 +0200)] 
Fix compilation on OpenBSD

Non-POSIX functions (like vasprintf() and swap16()) require
_BSD_SOURCE to be defined.

Signed-off-by: Benjamin Stürz <benni@stuerz.xyz>
2 years agoFix CMake check for posix_memalign and aligned_alloc
lawadr [Tue, 4 Apr 2023 13:53:35 +0000 (14:53 +0100)] 
Fix CMake check for posix_memalign and aligned_alloc

These two functions were being checked using check_function_exists. This
CMake macro does not check to see if the given function is declared in
any header as it declares its own function prototype and relies on
linking to determine function availability. This causes two issues.

Firstly, it will always succeed when the CMake toolchain file sets
CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY as no linking will take
place. See: https://gitlab.kitware.com/cmake/cmake/-/issues/18121

Secondly, it will not correctly detect macros or inline functions, or
whether the function is even declared in a header at all.

Switch to check_symbol_exists at CMake's recommendation, the logic of
which actually matches the same checks in the configure script.

2 years agoVersion 2.0.7 2.0.7
Hans Kristian Rosbach [Tue, 7 Mar 2023 09:31:47 +0000 (10:31 +0100)] 
Version 2.0.7

Changes since 2.0.6:
- Fix CVE-2022-37434 #1328
- Fix chunkmemset #1196
- Fix deflateBound too small #1236
- Fix Z_SOLO #1263
- Fix ACLE variant of crc32 #1274
- Fix inflateBack #1311
- Fix deflate_quick windowsize #1431
- Fix DFLTCC bugs related to adler32 #1349 and #1390
- Fix warnings #1194 #1312 #1362
- MacOS build fix #1198
- Add invalid windowBits handling #1293
- Support for Force TZCNT #1186
- Support for aligned_alloc() #1360
- Minideflate improvements #1175 #1238
- Dont use unaligned access for memcpy #1309
- Build system #1209 #1233 #1267 #1273 #1278 #1292 #1316 #1318 #1365
- Test improvements #1208 #1227 #1241 #1353
- Cleanup #1266
- Documentation #1205 #1359
- Misc improvements #1294 #1297 #1306 #1344 #1348
- Backported zlib fixes
- Backported CI workflows from Develop branch

2 years ago[minigzip] Close gzFile before exiting on error.
Mika T. Lindqvist [Fri, 10 Feb 2023 10:06:59 +0000 (12:06 +0200)] 
[minigzip] Close gzFile before exiting on error.

2 years agoNarrow down the amount of packages installed for Wine.
Hans Kristian Rosbach [Thu, 9 Feb 2023 11:04:09 +0000 (12:04 +0100)] 
Narrow down the amount of packages installed for Wine.

2 years agoHave build test report library version if it doesn't match zlib.h.
Mark Adler [Thu, 26 May 2022 15:47:51 +0000 (08:47 -0700)] 
Have build test report library version if it doesn't match zlib.h.

2 years agoHave infback() deliver all of the available output up to any error.
Mark Adler [Sun, 24 Jul 2022 18:41:07 +0000 (11:41 -0700)] 
Have infback() deliver all of the available output up to any error.

2 years agoFix bug in block type selection when Z_FIXED used.
Mark Adler [Sun, 2 Oct 2022 02:55:29 +0000 (19:55 -0700)] 
Fix bug in block type selection when Z_FIXED used.

A fixed block could be chosen when a stored block was smaller. Now
the smaller of the two is always chosen.

2 years agoAdd WIN32_LEAN_AND_MEAN for windows.h include.
Mark Adler [Mon, 3 Oct 2022 15:47:03 +0000 (08:47 -0700)] 
Add WIN32_LEAN_AND_MEAN for windows.h include.

2 years agoRemove redundant check in gz_look().
Mark Adler [Thu, 6 Oct 2022 19:57:31 +0000 (12:57 -0700)] 
Remove redundant check in gz_look().

2 years agoFix bug in deflateBound() for level 0 and memLevel 9.
Mark Adler [Thu, 15 Dec 2022 17:07:13 +0000 (09:07 -0800)] 
Fix bug in deflateBound() for level 0 and memLevel 9.

memLevel 9 would cause deflateBound() to assume the use of fixed
blocks, even if the compression level was 0, which forces stored
blocks. That could result in a bound less than the size of the
compressed data. Now level 0 always uses the stored blocks bound.

2 years agoFix crash when gzsetparams() attempted for transparent write.
Mark Adler [Tue, 27 Dec 2022 07:36:01 +0000 (23:36 -0800)] 
Fix crash when gzsetparams() attempted for transparent write.

gzsetparams() now returns a Z_STREAM_ERROR in this case.

2 years agoIBM Z DFLTCC: Test with MSan
Ilya Leoshkevich [Tue, 14 Jun 2022 09:19:29 +0000 (11:19 +0200)] 
IBM Z DFLTCC: Test with MSan

* Add __msan_unpoison() calls to DFLTCC inline assembly.
* Make parameter block sizes symbolic constants.
* Move dfltcc() definition after struct dfltcc_param_v0 definition.

Backported from commit 1f5ddcc009ac3511e99fc88736a9e1a6381168c5.

2 years agoUse _msan_unposion to unposion end of window for when it needs to read the past ...
Nathan Moinvaziri [Mon, 11 Apr 2022 02:35:12 +0000 (19:35 -0700)] 
Use _msan_unposion to unposion end of window for when it needs to read the past < chunksize bytes in the window. See #1245.

Co-authored-by: Adam Stylinski <kungfujesus06@gmail.com>
Backported from commit c882034d48afc0b32a38e8f7ca63a2e4e91ab42d.

2 years agoAdjust thread counts for compiles and tests to avoid under-utilization and congestion.
Hans Kristian Rosbach [Thu, 9 Feb 2023 00:51:09 +0000 (01:51 +0100)] 
Adjust thread counts for compiles and tests to avoid under-utilization and congestion.
The free Github Actions VMs have 2 cores, the dedicated s390x VM has 4 cores.

2 years agoUpdate abicheck
Hans Kristian Rosbach [Wed, 8 Feb 2023 19:11:16 +0000 (20:11 +0100)] 
Update abicheck

2 years agoBackport CMake toolchain files from current 'develop' branch.
Hans Kristian Rosbach [Wed, 8 Feb 2023 16:30:36 +0000 (17:30 +0100)] 
Backport CMake toolchain files from current 'develop' branch.

2 years agoBackport latest CI workflows from 'develop'.
Hans Kristian Rosbach [Wed, 8 Feb 2023 14:52:07 +0000 (15:52 +0100)] 
Backport latest CI workflows from 'develop'.
Removed tests for features not supported in 2.0.x:
- cxx related settings, as stable does not use gtest/gbench.
- Emscripten
- Add_subdirectory
- Symbol prefix
- oss-fuzz, their buildfile is incompatible with this branch

2 years agoFix inconsistent feature enablements in cmake and configure
Hans Kristian Rosbach [Wed, 8 Feb 2023 20:56:49 +0000 (21:56 +0100)] 
Fix inconsistent feature enablements in cmake and configure

2 years agoRemove gz_intmax implementation, since INT_MAX is always available in modern C implem...
Hans Kristian Rosbach [Mon, 13 Dec 2021 15:24:20 +0000 (16:24 +0100)] 
Remove gz_intmax implementation, since INT_MAX is always available in modern C implementations.

2 years agoRemove WindowBits check for level 1
Ruben Vorderman [Wed, 8 Feb 2023 08:03:42 +0000 (09:03 +0100)] 
Remove WindowBits check for level 1

2 years agoIBM zSystems DFLTCC: Fix updating strm.adler
Ilya Leoshkevich [Sat, 17 Sep 2022 13:32:29 +0000 (15:32 +0200)] 
IBM zSystems DFLTCC: Fix updating strm.adler

inflate() does not update strm.adler with DFLTCC.
deflate() updates strm.adler even for raw streams.
Fix by adding wrap checks.

2 years agoAdd CodeQL workflow for GitHub code scanning
LGTM Migrator [Wed, 9 Nov 2022 11:28:47 +0000 (11:28 +0000)] 
Add CodeQL workflow for GitHub code scanning

2 years agoMakefile.in: distclean should remove zlib.pc instead of clean
tch69 [Thu, 27 Oct 2022 14:42:19 +0000 (21:42 +0700)] 
Makefile.in: distclean should remove zlib.pc instead of clean

2 years ago[MinGW] Disable GCC warning about using MS format specifiers in ISO C conformant...
Mika Lindqvist [Thu, 13 Oct 2022 15:18:52 +0000 (18:18 +0300)] 
[MinGW] Disable GCC warning about using MS format specifiers in ISO C conformant code

2 years agoSupport using aligned_alloc() for memory allocation
Cameron Cawley [Thu, 13 Oct 2022 13:59:18 +0000 (14:59 +0100)] 
Support using aligned_alloc() for memory allocation

2 years agoFix typo in README.md
Cameron Cawley [Wed, 12 Oct 2022 21:21:21 +0000 (22:21 +0100)] 
Fix typo in README.md

2 years agoUse short decompress option name for gzip compatibility. #1347
Nathan Moinvaziri [Wed, 28 Sep 2022 16:38:06 +0000 (09:38 -0700)] 
Use short decompress option name for gzip compatibility. #1347

Long option names in BusyBoxy is an optional feature, so use short option
names by default.

2 years agoRemove unused tryboth() function
Hans Kristian Rosbach [Sun, 25 Sep 2022 15:59:44 +0000 (17:59 +0200)] 
Remove unused tryboth() function

2 years agoMake visibility tests run the same way as the other tests.
Hans Kristian Rosbach [Wed, 14 Sep 2022 19:29:41 +0000 (21:29 +0200)] 
Make visibility tests run the same way as the other tests.
Fix indentation.

2 years agoDon't try to link gz* objects twice.
Hans Kristian Rosbach [Wed, 14 Sep 2022 19:27:48 +0000 (21:27 +0200)] 
Don't try to link gz* objects twice.

2 years agoRemove errant space in cmake posix specifier
Hans Kristian Rosbach [Wed, 14 Sep 2022 19:26:32 +0000 (21:26 +0200)] 
Remove errant space in cmake posix specifier

2 years ago[Compat] Don't use uint32_t for z_crc_t
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

See #1342

2 years agoActually run `configure` CI on macOS with GCC
Mosè Giordano [Wed, 24 Aug 2022 19:39:03 +0000 (20:39 +0100)] 
Actually run `configure` CI on macOS with GCC

`gcc` is an alias for Apple Clang on macOS.  See for example https://github.com/zlib-ng/zlib-ng/runs/7963904948?check_suite_focus=true
```
gcc -O2  -std=c11 -Wall -fPIC -DNDEBUG -DHAVE_POSIX_MEMALIGN -DWITH_GZFILEOP -fno-semantic-interposition -DHAVE_VISIBILITY_HIDDEN -DHAVE_VISIBILITY_INTERNAL -DHAVE_BUILTIN_CTZ -DHAVE_BUILTIN_CTZLL -DX86_FEATURES -DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET -DX86_AVX512 -DX86_AVX512_ADLER32 -DX86_MASK_INTRIN -DX86_AVX512VNNI -DX86_AVX512VNNI_ADLER32 -DX86_SSE41 -DX86_SSE42_CRC_HASH -DX86_SSE42_ADLER32 -DX86_SSE42_CRC_INTRIN -DX86_SSE2 -DX86_SSE2_CHUNKSET -DX86_SSSE3 -DX86_SSSE3_ADLER32 -DX86_PCLMULQDQ_CRC -DPIC -I/Users/runner/work/zlib-ng/zlib-ng -c -o adler32.lo /Users/runner/work/zlib-ng/zlib-ng/adler32.c
clang: warning: argument unused during compilation: '-fno-semantic-interposition' [-Wunused-command-line-argument]
```

In order to use the real GCC you have to call `gcc-9`, `gcc-10`, or `gcc-11`: https://github.com/actions/runner-images/blob/06dd4c14e4aa8c14febdd8d6cf123b8d770b4e4a/images/macos/macos-11-Readme.md#language-and-runtime.

2 years agoAdd CVE-2022-37434 test.
Vladislav Shchapov [Fri, 19 Aug 2022 11:33:59 +0000 (16:33 +0500)] 
Add CVE-2022-37434 test.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2 years agoIf the extra field was larger than the space the user provided with
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.

See #1323.

2 years agocmake: respect custom `RC` flags and delete `GCC_WINDRES`
Viktor Szakats [Sun, 17 Jul 2022 19:33:01 +0000 (19:33 +0000)] 
cmake: respect custom `RC` flags and delete `GCC_WINDRES`

Before this patch, `zlib.rc` was compiled using a manual command [1] when
using the MinGW (and MSYS/Cygwin) toolchains. This method ignores
`CMAKE_RC_FLAGS` and offers no other way to pass a custom flag, breaking
the build in cases where a custom `windres` option is required. E.g.
`--target=` or `-I` on some platforms and configuration, in particular
with `llvm-windres`.

This patch deletes the special case for these toolchains and lets CMake
compile the `.rc` file the default way used for all Windows targets.

I'm not entirely sure why this special case was added back in 2011. The
need to pass `-DGCC_WINDRES` is my suspect. We can resolve this much
simpler by adding this line for the targets that require it:
   set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DGCC_WINDRES")

But, the `.rc` line protected by `GCC_WINDRES`, these days work just fine
with `windres`. Moreover, that protected line are oboslete flags from the
16-bit era, which for a long time have no effect, as documented here:
<https://docs.microsoft.com/windows/win32/menurc/common-resource-attributes>

So, this patch deletes `GCC_WINDRES` from the project entirely.

[1] dc5a43e

2 years agoTreat arm64 as aarch64 for Apple M1.
Mika Lindqvist [Sat, 9 Jul 2022 09:33:02 +0000 (12:33 +0300)] 
Treat arm64 as aarch64 for Apple M1.

2 years agoFixed functions declared without a prototype warning in tools.
Nathan Moinvaziri [Sat, 2 Jul 2022 20:59:19 +0000 (13:59 -0700)] 
Fixed functions declared without a prototype warning in tools.

  tools/maketrees.c:101:29: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
static void gen_trees_header()

  tools/makecrct.c:65:27: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
static void make_crc_table()

2 years agoFix inflateBack to detect invalid input with distances too far.
Mark Adler [Thu, 30 Jun 2022 19:04:27 +0000 (12:04 -0700)] 
Fix inflateBack to detect invalid input with distances too far.

2 years agoDon't use unaligned access for memcpy instructions due to GCC 11 assuming it is align...
Nathan Moinvaziri [Wed, 29 Jun 2022 15:57:11 +0000 (08:57 -0700)] 
Don't use unaligned access for memcpy instructions due to GCC 11 assuming it is aligned in certain instances.

Backport note: Removed a lot of the original commit due to merge conflicts

2 years agoDon't use zlib fork identifier in copyright statement.
Nathan Moinvaziri [Thu, 30 Jun 2022 18:23:23 +0000 (11:23 -0700)] 
Don't use zlib fork identifier in copyright statement.

2 years agoUse 15 (0xf) for ZLIB_VER_SUBREVISION to indicate zlib fork.
Nathan Moinvaziri [Thu, 30 Jun 2022 18:23:37 +0000 (11:23 -0700)] 
Use 15 (0xf) for ZLIB_VER_SUBREVISION to indicate zlib fork.

2 years agoIn compatibility mode, always define z_crc_t as uint32_t for backwards compatibility.
Mika Lindqvist [Fri, 17 Jun 2022 10:06:56 +0000 (13:06 +0300)] 
In compatibility mode, always define z_crc_t as uint32_t for backwards compatibility.

2 years agoExtend GZIP conditional
Tobias Stoeckmann [Mon, 13 Jun 2022 16:46:00 +0000 (18:46 +0200)] 
Extend GZIP conditional

If gzip support has been disabled during compilation then also
consider gzip relevant states as invalid in deflateStateCheck.

Also the gzip state definitions can be removed.

This change leads to failure in test/example, and I am not sure
what the GZIP conditional is trying to achieve. All gzip related
functions are still defined in zlib.h

Alternative approach is to remove the GZIP define.

2 years agoHandle invalid windowBits in init functions
Tobias Stoeckmann [Mon, 13 Jun 2022 16:43:16 +0000 (18:43 +0200)] 
Handle invalid windowBits in init functions

Negative windowBits arguments are eventually turned positive in
deflateInit2_ and inflateInit2_ (more precisely in inflateReset2).
Such values are used to indicate that raw deflate/inflate should
be performed.

If a user supplies INT32_MIN for windowBits, the code will perform
-INT32_MIN which does not fit into int32_t. In fact, this is
undefined behavior in C and should be avoided.

Clearly this is a user error, but given the careful validation of
input arguments a few lines later in deflateInit2_ I think this
might be of interest.

Proof of Concept:

- Compile zlib-ng with gcc -ftrapv or -fsanitize=undefined
- Compile and run this program:

```
 #include <limits.h>
 #include <stdio.h>
 #include <zlib-ng.h>

 int main(void) {
  zng_stream de_stream = { 0 }, in_stream = { 0 };
  int result;

  result = zng_deflateInit2(&de_stream, 0, Z_DEFLATED, INT32_MIN,
      MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  printf("zng_deflateInit2: %d\n", result);

  result = zng_inflateInit2(&in_stream, INT32_MIN);
  printf("zng_inflateInit2: %d\n", result);

  return 0;
 }
```

2 years agoAdd public compile definition for zlib-ng API so that other projects that use CMake...
Nathan Moinvaziri [Sun, 12 Jun 2022 16:01:15 +0000 (09:01 -0700)] 
Add public compile definition for zlib-ng API so that other projects that use CMake and link against the zlib project can easily determine whether or not to include "zlib-ng.h" or "zlib.h".

2 years agoCMakeLists.txt: fix version in zlib.pc when building statically
Fabrice Fontaine [Fri, 27 May 2022 21:25:21 +0000 (23:25 +0200)] 
CMakeLists.txt: fix version in zlib.pc when building statically

When building statically (i.e. with BUILD_SHARED_LIBS=OFF),
ZLIB_FULL_VERSION is not set resulting in an empty version in zlib.pc
and the following build failure with transmission:

checking for ZLIB... configure: error: Package requirements (zlib >= 1.2.3) were not met:

Package dependency requirement 'zlib >= 1.2.3' could not be satisfied.
Package 'zlib' has version '', required version is '>= 1.2.3'

Fixes:
 - http://autobuild.buildroot.org/results/b3b882482f517726e5c780ba4c37818bd379df82

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2 years agoearly return as requested
Lucy Phipps [Wed, 8 Jun 2022 17:48:19 +0000 (18:48 +0100)] 
early return as requested

2 years agoremove UNROLL_MORE as suggested
Lucinda May Phipps [Tue, 7 Jun 2022 13:59:39 +0000 (14:59 +0100)] 
remove UNROLL_MORE as suggested

2 years agocrc32_acle.c: make logic more consistent
Lucinda May Phipps [Fri, 13 May 2022 07:48:17 +0000 (08:48 +0100)] 
crc32_acle.c: make logic more consistent

2 years agoMake directory for output files.
Vladislav Shchapov [Thu, 12 May 2022 13:36:42 +0000 (18:36 +0500)] 
Make directory for output files.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2 years agoThe names CMAKE_INTERPROCEDURAL_OPTIMIZATION_* must be uppercase.
Vladislav Shchapov [Thu, 5 May 2022 11:51:17 +0000 (16:51 +0500)] 
The names CMAKE_INTERPROCEDURAL_OPTIMIZATION_* must be uppercase.

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2 years agoRemove unused chunkmemset_1 code.
Nathan Moinvaziri [Tue, 3 May 2022 22:40:44 +0000 (15:40 -0700)] 
Remove unused chunkmemset_1 code.

2 years agoDisable redirection to 64-bit function variants when Z_SOLO is defined
Mika Lindqvist [Tue, 3 May 2022 00:47:52 +0000 (03:47 +0300)] 
Disable redirection to 64-bit function variants when Z_SOLO is defined

See #1262.

2 years agoMimic minigzip behavior and only unlink files if not using -c copy out argument.
Nathan Moinvaziri [Fri, 8 Apr 2022 03:39:21 +0000 (20:39 -0700)] 
Mimic minigzip behavior and only unlink files if not using -c copy out argument.

2 years agoThrow an error when input is raw deflate stream but window_bits is not supplied.
Nathan Moinvaziri [Fri, 11 Mar 2022 23:45:06 +0000 (15:45 -0800)] 
Throw an error when input is raw deflate stream but window_bits is not supplied.

2 years agoPrint help when no arguments supplied to minideflate.
Nathan Moinvaziri [Fri, 11 Mar 2022 23:42:14 +0000 (15:42 -0800)] 
Print help when no arguments supplied to minideflate.

2 years agoAppend extension to output file path based on window_bits when compressing and remove...
Nathan Moinvaziri [Fri, 11 Mar 2022 23:31:57 +0000 (15:31 -0800)] 
Append extension to output file path based on window_bits when compressing and remove extension from output file path when decompressing.

2 years agoAdded support for -k keep argument to minideflate. By default minideflate will now...
Nathan Moinvaziri [Fri, 11 Mar 2022 22:53:47 +0000 (14:53 -0800)] 
Added support for -k keep argument to minideflate. By default minideflate will now delete the input file.

2 years agoUse large default buffer size for minideflate to match minigzip use of GZBUFSIZE.
Nathan Moinvaziri [Thu, 10 Mar 2022 16:57:13 +0000 (08:57 -0800)] 
Use large default buffer size for minideflate to match minigzip use of GZBUFSIZE.

2 years agoInclude zutil.h for definition of DEF_MEM_LEVEL.
Nathan Moinvaziri [Thu, 10 Mar 2022 16:53:44 +0000 (08:53 -0800)] 
Include zutil.h for definition of DEF_MEM_LEVEL.

2 years agoAuto-detect wrapper when inflating and no window_bits specified.
Nathan Moinvaziri [Mon, 28 Feb 2022 17:00:26 +0000 (09:00 -0800)] 
Auto-detect wrapper when inflating and no window_bits specified.

2 years agoUpdated help usage with correct values for window_bits.
Nathan Moinvaziri [Sun, 27 Feb 2022 18:06:13 +0000 (10:06 -0800)] 
Updated help usage with correct values for window_bits.

2 years agoFixed wrong error name when calling inflate in minideflate.
Nathan Moinvaziri [Wed, 23 Feb 2022 20:07:01 +0000 (12:07 -0800)] 
Fixed wrong error name when calling inflate in minideflate.

2 years agoFixed failed tools tests when source directory is read-only.
Nathan Moinvaziri [Sat, 9 Apr 2022 04:43:54 +0000 (21:43 -0700)] 
Fixed failed tools tests when source directory is read-only.

2 years agoDisable LTO in CMake
Vladislav Shchapov [Mon, 4 Apr 2022 08:37:12 +0000 (13:37 +0500)] 
Disable LTO in CMake

2 years agoAdd test for issue #1235.
Mika Lindqvist [Wed, 6 Apr 2022 20:49:24 +0000 (23:49 +0300)] 
Add test for issue #1235.
* Test both compressBound() and deflateBound() as those share same code fragment.

2 years agoAdd one extra byte to return value of compressBound and deflateBound for small length...
Mika Lindqvist [Tue, 5 Apr 2022 21:04:45 +0000 (00:04 +0300)] 
Add one extra byte to return value of compressBound and deflateBound for small lengths due to shift returning 0.
* Treat 0 byte input as 1 byte input when calculating compressBound and deflateBound

2 years agoabicheck.sh: zlib-ng is a bash script, not a sh script, don't hardcode shell when...
Dan Kegel [Fri, 1 Apr 2022 19:42:28 +0000 (19:42 +0000)] 
abicheck.sh: zlib-ng is a bash script, not a sh script, don't hardcode shell when running configure

2 years agoRemove unistd.h include from gzguts.h which is already included from zconf.h via...
Nathan Moinvaziri [Sat, 26 Mar 2022 17:37:29 +0000 (10:37 -0700)] 
Remove unistd.h include from gzguts.h which is already included from zconf.h via zlib.h.

2 years agoUse HAVE instead of HAS for variable name for consistency.
Nathan Moinvaziri [Sat, 26 Mar 2022 15:47:01 +0000 (08:47 -0700)] 
Use HAVE instead of HAS for variable name for consistency.

2 years agoTest CVE-2018-25032 against the default level and levels 1 and 2.
Nathan Moinvaziri [Thu, 31 Mar 2022 17:04:49 +0000 (10:04 -0700)] 
Test CVE-2018-25032 against the default level and levels 1 and 2.

2 years agoAdded unit test against CVE-2018-25032 with default strategy.
Nathan Moinvaziri [Mon, 28 Mar 2022 14:53:55 +0000 (07:53 -0700)] 
Added unit test against CVE-2018-25032 with default strategy.

Co-authored-by: Eric Biggers <ebiggers@kernel.org>
2 years agoAdded unit test against CVE-2018-25032.
Nathan Moinvaziri [Sun, 27 Mar 2022 00:49:49 +0000 (17:49 -0700)] 
Added unit test against CVE-2018-25032.
Sample input from https://www.openwall.com/lists/oss-security/2022/03/26/1.

Co-authored-by: Tavis Ormandy <taviso@users.noreply.github.com>
2 years agoAdded missing -F argument for Z_FIXED strategy in minideflate.
Nathan Moinvaziri [Sun, 27 Mar 2022 00:26:16 +0000 (17:26 -0700)] 
Added missing -F argument for Z_FIXED strategy in minideflate.

2 years agoUpdate language around ABI compatibility with zlib. #1081
Nathan Moinvaziri [Mon, 21 Mar 2022 18:58:07 +0000 (11:58 -0700)] 
Update language around ABI compatibility with zlib. #1081

2 years agoFix a latent issue with chunkmemset
Adam Stylinski [Fri, 18 Mar 2022 00:22:56 +0000 (20:22 -0400)] 
Fix a latent issue with chunkmemset

It would seem that on some platforms, namely those which are
!UNALIGNED64_OK, there was a likelihood of chunkmemset_safe_c copying all
the bytes before passing control flow to chunkcopy, a function which is
explicitly unsafe to be called with a zero length copy.

This fixes that bug for those platforms.

2 years agomacOs M1 build fix on arm cpu checks.
David CARLIER [Fri, 18 Mar 2022 21:01:00 +0000 (21:01 +0000)] 
macOs M1 build fix on arm cpu checks.

2 years agoWrong variable used when detecting unaligned support for sanitize
Nathan Moinvaziri [Thu, 17 Mar 2022 19:57:41 +0000 (12:57 -0700)] 
Wrong variable used when detecting unaligned support for sanitize

2 years ago[README] Add missing FORCE_SSE2 for CMake.
Mika Lindqvist [Mon, 14 Mar 2022 18:02:01 +0000 (20:02 +0200)] 
[README] Add missing FORCE_SSE2 for CMake.

2 years agoAllow bypassing runtime feature check of TZCNT instructions.
Mika Lindqvist [Sun, 13 Mar 2022 15:12:42 +0000 (17:12 +0200)] 
Allow bypassing runtime feature check of TZCNT instructions.
* This avoids conditional branch when it's known at build time that TZCNT instructions are always supported

2 years agoFix UBSAN's cry afoul
Adam Stylinski [Thu, 17 Mar 2022 02:52:44 +0000 (22:52 -0400)] 
Fix UBSAN's cry afoul

Technically, we weren't actually doing this the way C wants us to,
legally.  The zmemcpy's turn into NOPs for pretty much all > 0
optimization levels and this gets us defined behavior with the
sanitizer, putting the optimized load by arbitrary alignment into the
compiler's hands instead of ours.

Backport note: Replaced zmemcpy with direct memcpy, as that is what we
end up with in a later commit anyway.

2 years agoAdded ClangCl instances to GitHub Actions workflow.
Nathan Moinvaziri [Wed, 9 Mar 2022 22:57:22 +0000 (14:57 -0800)] 
Added ClangCl instances to GitHub Actions workflow.

3 years agoVersion 2.0.6 2.0.6
Hans Kristian Rosbach [Mon, 13 Dec 2021 14:26:26 +0000 (15:26 +0100)] 
Version 2.0.6
 - Fix hangs on macOS #1031
 - Fix minideflate write buffers being overwritten #1060
 - Fix deflateBound and compressBound returning too small size estimates #1049 #1071
 - Fix incorrect function declaration warning #1080
 - Fix build problems when building outside of source dir #1049
 - Fix build problems on arm2-7 #1030
 - Fixed some compile warnings #1020 #1036 #1037 #1048
 - Improved posix memalign support #888
 - Improvements to testing #637 #1026 #1032 #1035 #1049 #1051 #1056 #1063 #1067 #1079
 - Improvements for integration into other projects #1022 #1042
 - Code style fixes #637 #1040 #1050 #1075

3 years agoUpgrade version of GitHub checkout actions. #1078
Nathan Moinvaziri [Mon, 20 Dec 2021 16:15:40 +0000 (08:15 -0800)] 
Upgrade version of GitHub checkout actions. #1078

3 years agoFixed crc32_combine_gen declaration warning in zlib-ng API.
Nathan Moinvaziri [Mon, 20 Dec 2021 16:23:44 +0000 (08:23 -0800)] 
Fixed crc32_combine_gen declaration warning in zlib-ng API.

3 years agoIBM Z: Adjust compressBound() for DFLTCC
Ilya Leoshkevich [Mon, 11 Oct 2021 10:24:20 +0000 (12:24 +0200)] 
IBM Z: Adjust compressBound() for DFLTCC

When DFLTCC was introduced, deflateBound() was adjusted, but
compressBound() was not, leading to compression failures when using
compressBound() + compress() with poorly compressible data.

3 years agoIBM Z: Do not check inflateGetDictionary() with DFLTCC
Ilya Leoshkevich [Mon, 11 Oct 2021 11:47:20 +0000 (13:47 +0200)] 
IBM Z: Do not check inflateGetDictionary() with DFLTCC

The zlib manual does not specify a strict contract for
inflateGetDictionary(), it merely says that it "Returns the sliding
dictionary being maintained by inflate", which is an implementation
detail. IBM Z inflate's behavior differs from that of software, and
may change in the future to boot.

3 years agoLink crc32_test and infcover with $(CFLAGS)
Ilya Leoshkevich [Mon, 11 Oct 2021 10:36:28 +0000 (12:36 +0200)] 
Link crc32_test and infcover with $(CFLAGS)

This fixes link failures when using CFLAGS=-m31 on IBM Z. All the
other tests are already linked this way.

3 years agoFix deflateBound and compressBound returning very small size estimates.
Hans Kristian Rosbach [Mon, 13 Dec 2021 21:30:58 +0000 (22:30 +0100)] 
Fix deflateBound and compressBound returning very small size estimates.
Remove workaround in switchlevels.c, so we do actual testing of this.
Use named defines instead of magic numbers where we can.

3 years agoIBM Z: Run DFLTCC tests on the self-hosted builder
Ilya Leoshkevich [Wed, 4 Aug 2021 22:27:31 +0000 (00:27 +0200)] 
IBM Z: Run DFLTCC tests on the self-hosted builder

* Use the self-hosted builder instead of ubuntu-latest.
* Drop qemu-related settings from DFLTCC configurations.
* Install codecov only for the current user, since the self-hosted
  builder runs under a restricted non-root account.
* Use actions/checkout@v2 for configure checks, since for some reason
  actions/checkout@v1 cannot find git on the self-hosted builder.
* Update the testing section of the DFLTCC README.
* Add the infrastructure code for the self-hosted builder.

3 years agoAvoid warning C4295 when using Visual C++ and maintainer warnings are enabled.
Mika Lindqvist [Wed, 15 Dec 2021 07:18:03 +0000 (09:18 +0200)] 
Avoid warning C4295 when using Visual C++ and maintainer warnings are enabled.

3 years agoCOMP: Fix data loss warning
Jon Haitz Legarreta Gorroño [Sun, 10 Oct 2021 14:51:09 +0000 (10:51 -0400)] 
COMP: Fix data loss warning

Fix data loss warning.

Fixes:
```
itkzlib-ng/inflate.c(1209,24): warning C4267: '=': conversion from 'size_t' to 'unsigned long', possible loss of data
itkzlib-ng/inflate.c(1210,26): warning C4267: '=': conversion from 'size_t' to 'unsigned long', possible loss of data
```

3 years agoFix UB in inffast.c when not using window
Ori Livneh [Mon, 23 Aug 2021 16:40:19 +0000 (12:40 -0400)] 
Fix UB in inffast.c when not using window

When not using window, `window + wsize` applies a zero offset to a null pointer, which is undefined behavior.

3 years agoFix hangs on macOS due to loading of misaligned addresses in chunkmemset_8.
Sergey Markelov [Thu, 22 Jul 2021 17:23:26 +0000 (10:23 -0700)] 
Fix hangs on macOS due to loading of misaligned addresses in chunkmemset_8.

3 years agoStandardize crc32_stub
Matheus Castanho [Wed, 16 Jun 2021 17:36:24 +0000 (14:36 -0300)] 
Standardize crc32_stub

Reorganize statements inside crc32_stub() to match more closely the format
used for other function stubs in functable.c.

3 years agoFixed missing enclosing parentheses for ZSWAP64 in zutil.h to avoid erroneous result...
cenobit [Sat, 26 Jun 2021 02:57:00 +0000 (19:57 -0700)] 
Fixed missing enclosing parentheses for ZSWAP64 in zutil.h to avoid erroneous result in inffast.c.

3 years agoFixed undefined behavior of isgraph when character is not in the range 0 through...
Nathan Moinvaziri [Tue, 17 Aug 2021 17:12:37 +0000 (10:12 -0700)] 
Fixed undefined behavior of isgraph when character is not in the range 0 through 0xFF inclusive.