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
Nathan Moin Vaziri
483f0568b0
mz_os: skip symlink check at or above destination dir
...
mz_dir_has_unsafe_symlink walks every component of the destination
path and rejects any symlink with an absolute target. That's too
strict: when the user-chosen destination dir (or one of its ancestors)
happens to be a symlink, extracting into it gets rejected with -107.
The check only needs to police symlinks that appear strictly inside
the destination, since those could be zip-controlled.
Skip the symlink check when check_path is at or above base_path; let
the existing logic enforce on components below.
Fixes #943 .
2026-04-25 01:21:33 -07:00
Nathan Moinvaziri
0574b3b815
Allocate symlink buffers on first use
2026-01-30 10:03:21 -08:00
Nathan Moinvaziri
32747dc514
Use fixed buffer size for symlink target instead of path length
2026-01-27 09:31:40 -08:00
Nathan Moinvaziri
9963dd30c5
Add buffer overflow check in mz_os_read_symlink function #944
2026-01-27 09:29:49 -08:00
Nathan Moinvaziri
bb282ace22
Fixed arbitrary file write vulnerability via symlinks. #936
2026-01-21 13:48:10 -08:00
Cœur
c7b6cb09e9
fix: unzipping with backslashes in the name on UNIX
2025-04-14 13:41:49 -07:00
Nathan Moinvaziri
2c51fa719e
Clang-format style changes.
2024-11-01 16:37:57 -07:00
pmqs
3417608874
Check for zero length path in mz_path_has_slash
...
Fix for https://github.com/zlib-ng/minizip-ng/issues/739
2023-11-13 09:38:50 -08:00
pmqs
3920698d13
Fix for filenames of the form "x/../y"
...
https://github.com/zlib-ng/minizip-ng/issues/740
2023-11-13 09:36:10 -08:00
pmqs
145754983c
Get mz_dir_make to test for an empty path
...
fixes https://github.com/zlib-ng/minizip-ng/issues/737
2023-10-26 10:03:09 -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
5dd5fe0906
Add missing string.h include for strdup.
2023-03-31 18:21:47 -07:00
Nathan Moinvaziri
c9fc27ccee
Use calloc instead of malloc + memset and use strdup where possible.
2023-02-24 14:35:31 -08: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
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
Nathan Moinvaziri
848c3e3503
Removed empty lines.
2022-11-29 17:19:49 -08:00
Peter Harris
27f2ff225f
Fix buffer overrun in mz_dir_make
...
If a path of length 0x10001 is passed into this function, the value of
len after truncating to int16_t will be greater than 0, so the function
will proceed to allocate a 2 byte buffer and copy 65538 bytes into it.
Avoid issues with truncation by keeping len in size_t.
2022-02-17 08:50:35 -08:00
Peter Harris
76de77b2e2
Fix buffer overrun in mz_path_combine
...
The path may be overrun by two bytes. One because mz_path_append_slash
may append to path without updating path_len, and another one because
strncat always appends a NUL byte after writing N bytes.
Rescan the path length and subtract one from the strncat length parameter
to make sure we stay within max_path.
2022-02-16 10:40:17 -08:00
Nathan Moinvaziri
db95894646
Updated name of project to minizip-ng.
2021-01-23 16:19:05 -08:00
Nathan Moinvaziri
70811ac6f5
Remove version number from headers.
2020-06-19 21:21:12 -07:00
Nathan Moinvaziri
ea9d986394
Remove extra unnecessary check for null-terminator.
2020-06-14 22:00:02 -07:00
Nathan Moinvaziri
dc6962b5fa
Use same brace style as zlib.
2020-06-14 22:00:02 -07:00
Nathan Moinvaziri
2aa369c468
Version 2.9.3.
2020-05-21 07:31:09 -07:00
Nathan Moinvaziri
b39f7a0e89
Version 2.9.2.
2020-02-12 08:38:09 -08:00
Nathan Moinvaziri
370ab036f3
Version 2.9.1.
2019-11-15 13:24:17 -08:00
Nathan Moinvaziri
d82ea2c654
Added more test cases for path resolving.
...
Fixed branching in resolve function.
2019-11-03 16:44:58 -08:00
Nathan Moinvaziri
e22948c731
Fixed path not resolving properly when previous output buffer contains certain characters. #433
2019-10-29 16:46:55 -07:00
Nathan Moinvaziri
8d6875d9c2
Fixed path not resolving properly when it begins with ..\ more than once. #433
2019-10-23 22:21:21 -07:00
Nathan Moinvaziri
10ac291d91
Version 2.9.0.
2019-09-18 16:55:43 -07:00
Nathan Moinvaziri
32fd805440
Version 2.8.9.
2019-07-04 10:32:02 -07:00
Nathan Moinvaziri
fbfd4e82f7
Version 2.8.8.
2019-05-22 17:50:39 -07:00
Nathan Moinvaziri
64c4c7f868
Version 2.8.7.
2019-05-09 18:46:18 -07:00
Nathan Moinvaziri
7d94b1ffa1
Fixed symbolic link issues on win32. Ensure that reading a symbolic link dir on windows produces linkname with slash at the end for recreation.
2019-05-08 23:41:47 -07:00
Nathan Moinvaziri
3a941ef473
Return forward slashed path from mz_os_read_symlink on windows.
2019-05-08 19:24:09 -07:00
Nathan Moinvaziri
a5a1d5d272
Store symbolic links in UNIX1 extra field instead of file attributes.
...
Correct reading of UNIX1 extra field timestamps.
Added option to store links to minizip cmd.
2019-05-05 20:13:58 -07:00
Nathan Moinvaziri
36f61523a3
Remove multiple slashes if they occur on the end of a path.
2019-05-05 08:19:14 -07:00
Nathan Moinvaziri
3249eac087
Added support for symbolic links. ZipArchive/ZipArchive#424 .
2019-05-02 21:07:39 -07:00
Nathan Moinvaziri
3c438164bd
Added gzip example app.
2019-04-28 09:23:56 -07:00
Nathan Moinvaziri
4fe0687243
Version 2.8.6.
2019-04-08 13:26:32 -07:00
Nathan Moinvaziri
488f20ff1b
Version 2.8.5.
2019-03-17 09:38:10 -07:00
Nathan Moinvaziri
9805ab4117
Version 2.8.4.
2019-02-14 17:16:01 -08:00
Nathan Moinvaziri
2e2f995eda
Version 2.8.3.
2019-01-26 16:49:48 -08:00
Nathan Moinvaziri
2ca7f3950c
Version 2.8.2.
2019-01-08 16:07:10 -08:00
Nathan Moinvaziri
b150432588
Fixed filename not being removed from path in certain instances.
2019-01-07 13:09:16 -08:00
Nathan Moinvaziri
1ff40343b5
Version 2.8.1.
2018-12-01 09:59:19 -08:00
Nathan Moinvaziri
5cb88b8f09
Version 2.8.0.
2018-11-24 17:59:11 -08:00
Nathan Moinvaziri
b16ab566ef
Change comments to C89 style.
...
Added _POSIX_C_SOURCE definition for necessary version of POSIX.
2018-11-20 16:56:21 -08:00
Nathan Moinvaziri
1ee609b759
Make inttypes.h optional. #345
2018-11-19 21:34:35 -08:00