Commit graph

177 commits

Author SHA1 Message Date
Nathan Moin Vaziri
131d59ba39 fix: reject symlink targets that escape extraction dir
Symlink archive entries had their stored target passed directly to
mz_os_make_symlink without checking containment, so a malicious
archive could create a link pointing outside the extraction root.

Add mz_path_is_symlink_target_safe to verify a link target resolves
within the destination directory, and apply it to both the UNIX1
extrafield and entry-content link targets. Reject symlink entries
outright when no destination base is set, since the target cannot be
validated without one.

Assisted-By: Claude Opus 4.8
2026-06-29 15:25:48 -07:00
Sergei
181642d2f8 test: improve: validate cipher bytes after encryption
The independent cipher bytes (encrypted text) are gotten on a 3rd party site.
2026-06-26 15:34:49 -07:00
Nathan Moin Vaziri
20fb0e3fdf
test: always compile the codec-gated test sources
These test files were conditionally added to the test target by CMake,
so their in-source guards never ran in the excluded configurations.
Compile them unconditionally and let the ifdef guards select the tests.
test_compat.cc keeps its MZ_COMPAT gate in CMake since the compatibility
layer is only built then, but its compression requirement moves into the
source.

Assisted-By: Claude Opus 4.8
2026-06-24 10:48:53 -07:00
Nathan Moin Vaziri
e6f15b4ae9
test: build stream compression tests only with compression
The stream tests compress then decompress, but the deflate path returns
MZ_SUPPORT_ERROR when built with MZ_ZIP_NO_COMPRESSION, so the round
trip cannot run. Guard the tests on that macro, and exclude only the
inflate-and-compare half when MZ_ZIP_NO_DECOMPRESSION is set.

Assisted-By: Claude Opus 4.8
2026-06-24 10:22:56 -07:00
Nathan Moin Vaziri
8c5f95cde7
test: don't run alternative data stream test on non-Windows platforms 2026-06-24 09:58:34 -07:00
Nathan Moin Vaziri
ece5b06dcf test: skip AES-GCM test when build doesn't support it
The Apple crypto backend defaults MZ_TARGET_APPSTORE to 1, which
makes mz_crypt_aes_set_key return MZ_SUPPORT_ERROR for GCM mode
because the GCM CommonCrypto APIs are private and rejected by App
Store review. The test was hard-coded to expect MZ_OK and failed on
the default macOS build.

Skip the test when the runtime reports MZ_SUPPORT_ERROR; otherwise
proceed and verify correctness as before.
2026-04-25 01:24:48 -07:00
Nathan Moin Vaziri
c37440f253
Build libc++ with MSAN instrumentation for gtest_minizip
gtest_minizip fails under MSAN with use-of-uninitialized-value in
std::basic_string's small-string-optimization union during static
TEST() registration, because system libstdc++ (and Ubuntu's libc++)
are not built with MSAN. We follow zlib-ng's approach.
2026-04-22 20:59:10 -07:00
Sergey
2f074dc2b6
cmake: improve: mz.h, mz_os.h are public API, shouldn't rely on user -D (#978) 2026-04-20 17:26:22 -07:00
Nathan Moinvaziri
41ad65fc10
Add TearDown cleanup for compat test temp files 2026-02-03 14:17:11 -08:00
Nathan Moinvaziri
c8c49425fc
Add TearDown cleanup for encrypt test temp files 2026-02-03 13:47:39 -08:00
Cœur
333bb8e84a
Document that mz_zip_tm_to_time_t requires a year-1900 indexed time struct. (#951) 2026-02-02 22:19:56 -05:00
Paul Marquess
12cd14990b
Add PPMd & Zstd zip files to the fuzz corpus (#954) 2026-02-02 14:05:39 -05:00
Paul Marquess
5880418f43
Add support for PPMd compression 2026-01-30 10:03:22 -08:00
pmqs
92eecea9cd
Replace deprecated FetchContent_GetProperties with FetchContent_MakeAvailable 2026-01-30 10:03:21 -08:00
Cœur
6e5e01a1ec Bump GoogleTest to 1.16 2025-11-07 10:18:23 -08:00
Cœur
f8941493a0 Adding MZ_PRESERVE_NATIVE_STRUCTURE to control the behavior. 2025-04-14 13:41:49 -07:00
Cœur
1eb579d9bc updating test expectations 2025-04-14 13:41:49 -07:00
Cœur
c7b6cb09e9 fix: unzipping with backslashes in the name on UNIX 2025-04-14 13:41:49 -07:00
tbeu
1529686f37 Apply Clang format 2025-03-23 14:09:01 -07:00
Gabriel Landau
888d4713f6 Add gtest validating mz_os_get_file_date works on ADS 2025-01-07 21:58:03 -08:00
Cœur
6d45beb98d ignore number_entry_cd when recover 2024-11-18 12:38:38 -05:00
Mikhail Khachayants
d7f5fdd19a fix and improve fuzzers 2024-11-14 18:07:14 -05:00
Nathan Moinvaziri
7df56f7cc8 Split compat layer into different source files #806 2024-10-30 18:11:27 -04:00
Nathan Moinvaziri
2f380cbbbf Upgrade to GoogleTest Framework v1.13.0. 2024-06-07 19:26:12 -07:00
Tulio Magno Quites Machado Filho
fbd8443122 Fix unzLocateFile 3rd parameter
Replace the previous type with one that is compatible with an int in
order to be identical to the interface used in madler's zlib.

Fixes #745.
2023-12-11 13:47:31 -08:00
Nathan Moinvaziri
933cedf2bb Added poc zip file for unzip fuzzer from GH issue #739. 2023-11-13 09:40:13 -08:00
Nathan Moinvaziri
42b6b8997c Added poc zip file for unzip fuzzer from GH issue #740. 2023-11-13 09:37:41 -08:00
Thomas Gamper
83301fc2a1 mz_os.h - fix indentation; mz_os_win32.c - adjust for utf8 strings to be represented by char*; test_encoding.cc - remove useless cast 2023-06-08 11:25:14 -07:00
Thomas Gamper
0fa804504c Adjust mz_os_utf8_string_create to return char*, and mz_os_utf8_string_delete to take a char** 2023-06-08 11:25:14 -07:00
Sergey Markelov
1e2d77345a Fix test crypt.rand: random_bytes[0] can be 0, std::string(random_bytes)
gets empty C string.
2023-05-17 15:50:06 -07:00
Sergey Markelov
1fdcfef544 Support AAD in AES-GCM 2023-05-05 13:53:16 -04:00
Nathan Moinvaziri
780459d80c Change to use encrypt/decrypt final functions in mz_aes. 2023-04-26 19:58:41 -07:00
Nathan Moinvaziri
c958ac8f7c Add unit test for any length in AES-GCM. 2023-04-26 19:58:29 -07:00
Nathan Moinvaziri
99efb55637 Clean up and rename mz_crypt_aes interface. 2023-04-26 10:45:44 -07:00
Nathan Moinvaziri
faf14369d9 Rename crypto unit tests. 2023-04-26 09:47:27 -07:00
Nathan Moinvaziri
1c24464e50 Implement verification of AES-GCM tag with OpenSSL. 2023-04-25 23:28:37 -07:00
Nathan Moinvaziri
8964058d0c Added AES-GCM unit test and fixed BCrypt code. 2023-04-25 23:27:50 -07:00
Nathan Moinvaziri
b366e5cc6f Improve hmac unit test with multiple calls to update. 2023-04-25 18:17:40 -07:00
Nathan Moinvaziri
c74bb95701 Skip unsupported SHA hash algorithms in unit tests. 2023-04-24 10:28:54 -07:00
Nathan Moinvaziri
ce42d1e81c Added support for OpenSSL version 3. 2023-04-18 13:49:06 -07:00
Nathan Moinvaziri
fcde5c5ba7 Added optional support for AES CBC mode to mz_crypt_aes. 2023-04-17 14:32:06 -07:00
Nathan Moinvaziri
3394c29b52 Fixed wrong usage of create function for sha224 test. 2023-04-09 11:14:26 -07:00
Nathan Moinvaziri
f9203e7a55 Remove SHA224 support for Windows. 2023-04-09 11:14:26 -07:00
Nathan Moinvaziri
217adc9363 Remove first param from create functions.
Better handle low memory situations.
2023-04-09 11:14:26 -07:00
Nathan Moinvaziri
5f5d899164 Added PBKDF2 test vectors. 2023-04-07 18:22:07 -07:00
Mircea Baja
2eb6305346 Fixed incorrect handling of long odd length passwords 2023-03-14 09:40:49 -07:00
Nathan Moinvaziri
261041dabc Remove useless MZ_CUSTOM_ALLOC and MZ_CUSTOM_FREE.
It would have required an include to make it useful.
2023-02-24 14:23:04 -08:00
Nathan Moinvaziri
ffe32766e0 Fixed formatting in fuzzers. 2023-02-19 16:04:32 -08:00
Nathan Moinvaziri
f07faecdde Remove all comparisons to NULL. 2023-02-19 16:04:13 -08:00
Nathan Moinvaziri
03e4d2213d Remove copyright years. 2023-02-16 13:14:21 -08:00