]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
7 days agolz4: Detect truncation in lz4_filter_read 3093/head
Tobias Stoeckmann [Thu, 28 May 2026 15:43:32 +0000 (17:43 +0200)] 
lz4: Detect truncation in lz4_filter_read

If __archive_read_filter_consume fails, report information about
detected truncation.

In many cases, the return value can be ignored since
__archive_read_ahead already performed the check. In this case, we never
read the data before, so add the check here.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agolz4: Avoid integer overflow in lz4_filter_read
Tobias Stoeckmann [Thu, 28 May 2026 15:39:41 +0000 (17:39 +0200)] 
lz4: Avoid integer overflow in lz4_filter_read

Integer promotion stops at unsigned int, thus addition of 4 to a
uint32_t can lead to an integer overflow.

Use int64_t to support all values.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agolz4: Add check for proper byte skipping
Tobias Stoeckmann [Fri, 29 May 2026 15:34:46 +0000 (17:34 +0200)] 
lz4: Add check for proper byte skipping

Check if truncated input is detected while skipping data.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoMerge pull request #3079 from i1011/win-ci-missing-errcheck-fix
Dustin L. Howett [Thu, 28 May 2026 21:56:46 +0000 (16:56 -0500)] 
Merge pull request #3079 from i1011/win-ci-missing-errcheck-fix

CI: Add missing exit on error in windows CI

8 days agoMerge pull request #3087 from stoeckmann/cygwin_rar
Dustin L. Howett [Thu, 28 May 2026 21:56:36 +0000 (16:56 -0500)] 
Merge pull request #3087 from stoeckmann/cygwin_rar

rar: Simplify FILE_ATTRIBUTE_DIRECTORY check

8 days agorar: Simplify FILE_ATTRIBUTE_DIRECTORY check 3087/head
Tobias Stoeckmann [Wed, 27 May 2026 20:01:45 +0000 (22:01 +0200)] 
rar: Simplify FILE_ATTRIBUTE_DIRECTORY check

Just check if the definition exists. If not, create it.
Fixes Cygwin build.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoMerge pull request #3083 from stoeckmann/read_int_overflow
Tobias Stoeckmann [Thu, 28 May 2026 20:46:43 +0000 (22:46 +0200)] 
Merge pull request #3083 from stoeckmann/read_int_overflow

Fix integer overflow in __archive_read_filter_ahead

8 days agoMerge pull request #3084 from stoeckmann/filters_total_out
Tobias Stoeckmann [Thu, 28 May 2026 20:46:23 +0000 (22:46 +0200)] 
Merge pull request #3084 from stoeckmann/filters_total_out

Drop total_out tracking from read filters

9 days agoDrop total_out tracking from read filters 3084/head
Tobias Stoeckmann [Wed, 27 May 2026 20:37:24 +0000 (22:37 +0200)] 
Drop total_out tracking from read filters

The variable is never read and it only allows a very unlikely integer
overflow if more than INT64_MAX bytes are read.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days agoMerge pull request #3080 from stoeckmann/tests_skip
Tobias Stoeckmann [Wed, 27 May 2026 20:01:10 +0000 (22:01 +0200)] 
Merge pull request #3080 from stoeckmann/tests_skip

tests: Fix memory leaks when skipping

9 days agoFix integer overflow in __archive_read_filter_ahead 3083/head
Tobias Stoeckmann [Wed, 27 May 2026 19:54:42 +0000 (21:54 +0200)] 
Fix integer overflow in __archive_read_filter_ahead

The pointer arithmetic could overflow with a large min value. Prevent
this by using subtraction instead of addition.

Resolves #3025.

Co-authored-by: ypp <alen0421@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days agotests: Fix memory leaks when skipping 3080/head
Tobias Stoeckmann [Wed, 27 May 2026 18:09:00 +0000 (20:09 +0200)] 
tests: Fix memory leaks when skipping

Release all resources when skipping to avoid ASAN memory leak warnings.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days agoCI: Add missing exit on error in windows CI 3079/head
i1011 [Wed, 27 May 2026 17:32:04 +0000 (01:32 +0800)] 
CI: Add missing exit on error in windows CI

10 days agoMerge pull request #3061 from tosanjay/warc-header-popul-ehdr-leak
Tim Kientzle [Wed, 27 May 2026 04:02:28 +0000 (21:02 -0700)] 
Merge pull request #3061 from tosanjay/warc-header-popul-ehdr-leak

warc writer: free hdr on _popul_ehdr overflow in _warc_header

10 days agoMerge pull request #3078 from vlmarek/solaris-skip-string-conversion-fail-tests
Tim Kientzle [Wed, 27 May 2026 03:29:44 +0000 (20:29 -0700)] 
Merge pull request #3078 from vlmarek/solaris-skip-string-conversion-fail-tests

Skip tests where Solaris iconv substitutes invalid chars

10 days agoMerge pull request #3067 from fdegros/fix-7z-seek-null-error
Dustin L. Howett [Tue, 26 May 2026 22:35:41 +0000 (17:35 -0500)] 
Merge pull request #3067 from fdegros/fix-7z-seek-null-error

7-Zip: Set error message in case of error

10 days ago7-Zip: Set error message when reading ahead fails 3067/head
François Degros [Mon, 25 May 2026 05:27:37 +0000 (15:27 +1000)] 
7-Zip: Set error message when reading ahead fails

Nice to have more explicit error messages.

10 days ago7-Zip: Set error message when seeking fails
François Degros [Mon, 25 May 2026 05:27:21 +0000 (15:27 +1000)] 
7-Zip: Set error message when seeking fails

Avoid (null) error message when seeking fails (e.g. on filtered
streams).

Fixes #2956

10 days agoMerge pull request #3077 from stoeckmann/32build
Tobias Stoeckmann [Tue, 26 May 2026 20:06:54 +0000 (22:06 +0200)] 
Merge pull request #3077 from stoeckmann/32build

32 bit: Fix compile warnings and test failure

10 days agoSkip tests where Solaris iconv substitutes invalid chars 3078/head
Vladimír Marek [Tue, 26 May 2026 19:27:05 +0000 (21:27 +0200)] 
Skip tests where Solaris iconv substitutes invalid chars

Solaris iconv may perform an implementation-defined conversion for
non-identical characters instead of failing. In the tested conversions it
substitutes question marks and reports success, so these negative tests do
not match Solaris behavior.

10 days agoMerge pull request #3049 from KongQBin/master
Dustin L. Howett [Tue, 26 May 2026 19:38:40 +0000 (14:38 -0500)] 
Merge pull request #3049 from KongQBin/master

build: fix global state leakage in crypto/library checks

10 days agoMerge pull request #3075 from stoeckmann/tests_close
Dustin L. Howett [Tue, 26 May 2026 19:24:46 +0000 (14:24 -0500)] 
Merge pull request #3075 from stoeckmann/tests_close

tests: Use assertEqualIntA for archive_*_close

10 days agotests: Fix 32 bit time_t check 3077/head
Tobias Stoeckmann [Tue, 26 May 2026 19:17:01 +0000 (21:17 +0200)] 
tests: Fix 32 bit time_t check

On systems with a 32 bit time_t, archive_parse_date covers less values
than with a 64 bit time_t.

Adjust the expected return value for an overly large value.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
10 days ago7zip: Fix format modifier in init_decompression
Tobias Stoeckmann [Tue, 26 May 2026 19:16:28 +0000 (21:16 +0200)] 
7zip: Fix format modifier in init_decompression

The codec field is of type uint64_t, which is an unsigned long on many
64 bit platforms (LP64), but 32 bit platforms and LLP64 platforms cannot
use the l modifier for correct output.

Cast to uintmax_t for portable j support.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
10 days agoMerge pull request #2972 from stoeckmann/rr_moved
Tobias Stoeckmann [Tue, 26 May 2026 19:14:32 +0000 (21:14 +0200)] 
Merge pull request #2972 from stoeckmann/rr_moved

iso9660: Add test for #2978

10 days agoiso9660: Add Rock Ridge regression test 2972/head
Tobias Stoeckmann [Mon, 20 Apr 2026 18:29:17 +0000 (20:29 +0200)] 
iso9660: Add Rock Ridge regression test

The Rock Ridge rr_move functionality for paths with a depth larger than 8
has a few bugs in it. For one, it might loop over the same entries over
and over. And second, rr_move/ directory entries are not verified to be
unique. Both issues can lead to NULL pointer dereferences.

Add a test case which highlights the NULL pointer dereference.

Based on issue #2936.

10 days agoMerge pull request #3055 from stoeckmann/cpio_uaf
Dustin L. Howett [Tue, 26 May 2026 19:00:53 +0000 (14:00 -0500)] 
Merge pull request #3055 from stoeckmann/cpio_uaf

cpio: Fix UAF in error path
Add entry only after its full initialization into list. Otherwise the error handling of a failing strdup would have to unlink the entry again.

Fixes: 16ad9310733e ("cpio reader: Validate pathname in record_hardlink")
Resolves #3053.

10 days agotests: Use assertEqualIntA for archive_*_close 3075/head
Tobias Stoeckmann [Tue, 26 May 2026 18:54:42 +0000 (20:54 +0200)] 
tests: Use assertEqualIntA for archive_*_close

In case of errors, assertEqualIntA offers more information by accessing
archive's errno and error message.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
10 days agoMerge pull request #3050 from stoeckmann/bzip2_large
Tobias Stoeckmann [Tue, 26 May 2026 18:00:19 +0000 (20:00 +0200)] 
Merge pull request #3050 from stoeckmann/bzip2_large

bzip2: Support large in-memory archives

10 days agoMerge pull request #3072 from stoeckmann/tests_free
Tobias Stoeckmann [Tue, 26 May 2026 17:59:56 +0000 (19:59 +0200)] 
Merge pull request #3072 from stoeckmann/tests_free

tests: Avoid assertEqualIntA with archive_*_free

10 days agoMerge pull request #3074 from stoeckmann/7zip_stream
Tobias Stoeckmann [Tue, 26 May 2026 17:59:38 +0000 (19:59 +0200)] 
Merge pull request #3074 from stoeckmann/7zip_stream

7zip: Support streamable reading again

11 days agobuild: fix global state leakage in crypto/library checks 3049/head
KongQBin [Tue, 19 May 2026 10:19:53 +0000 (18:19 +0800)] 
build: fix global state leakage in crypto/library checks

The CMake build script was modifying global CMake variables (CMAKE_REQUIRED_LIBRARIES
and CMAKE_REQUIRED_INCLUDES) during crypto library checks (OpenSSL, MbedTLS, Nettle)
and Haiku libbsd checks without saving/restoring them using
CMAKE_PUSH_CHECK_STATE() and CMAKE_POP_CHECK_STATE().

This caused side effects where subsequent system-level checks (like
CHECK_TYPE_SIZE or CHECK_FUNCTION_EXISTS) inherited these library dependencies,
leading to incorrect feature detection in cross-compilation environments
(e.g., reporting that basic types like 'pid_t' are missing).

This patch ensures all such checks are properly scoped, improving build
robustness across different architectures (x86_64, AArch64, MIPS64, LoongArch64, etc.)
and cross-toolchain environments.

11 days ago7zip: Support streamable reading again 3074/head
Tobias Stoeckmann [Mon, 25 May 2026 21:45:34 +0000 (23:45 +0200)] 
7zip: Support streamable reading again

The slurp_central_directory function has been changed to always use
seek, which is not needed and also breaks streamable 7-Zip archives.

Resolves an issue observed in #3068.

Fixes: 71ef1c385249 ("7zip: Merge skip_sfx into get_data_offset")
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
11 days agotests: Avoid assertEqualIntA with archive_*_free 3072/head
Tobias Stoeckmann [Mon, 25 May 2026 18:36:39 +0000 (20:36 +0200)] 
tests: Avoid assertEqualIntA with archive_*_free

In case of errors, assertEqualIntA accesses the given archive and prints
diagnostic information about errno and error string.

Since archive_read_free and archive_write_free free the memory of the
archive, this would just lead to memory issues in case of errors.

Use assertEqualInt instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days ago warc writer: free hdr on _popul_ehdr overflow in _warc_header 3061/head
SanjayR [Fri, 22 May 2026 05:03:56 +0000 (10:33 +0530)] 
  warc writer: free hdr on _popul_ehdr overflow in _warc_header

  _warc_header() initialises a local archive_string hdr, fills it via
  _popul_ehdr(), and frees it on the success path at the bottom. The
  intermediate error return on r < 0 (the populated header exceeds
  MAX_HDR_SIZE=512, reachable with a long enough pathname carried by
  WARC-Target-URI) returns ARCHIVE_WARN without freeing hdr.

  By the time _popul_ehdr returns -1 hdr already holds the WARC version
  line, WARC-Type, WARC-Target-URI (long path), WARC-Date, Last-Modified,
  WARC-Record-ID, and Content-Length headers --- ~1 KB+ per entry in
  practice.

  Reproduces with the bundled bsdtar against a regular file with a
  ~400+ char pathname:
      ASAN_OPTIONS=detect_leaks=1 bsdtar --format=warc -cf out.warc <long_path>
  => LeakSanitizer: ~1 KB direct leak; stack pierces _popul_ehdr ->
     _warc_header (archive_write_set_format_warc.c:245) ->
     _archive_write_header -> ... -> main.

  Code unchanged since the file's introduction in 2014; no existing test
  exercises the long-pathname path. The warcinfo branch above (line ~217)
  handles this correctly already (frees hdr unconditionally outside the
  "if (r >= 0)" block); only the WT_RSRC branch was missed.

  Identified by Neurolog, a code-analysis tool the reporter is developing
  that combines Souffle Datalog with LLM-assisted fact extraction. The
  reproducer was hand-validated under LeakSanitizer against current master.

12 days agoMerge pull request #2790 from LumioseSil/SetFilePointerEx_perso
Dustin L. Howett [Sun, 24 May 2026 19:59:52 +0000 (14:59 -0500)] 
Merge pull request #2790 from LumioseSil/SetFilePointerEx_perso

Replace SetFilePointerEx_perso (local reimplementation) with SetFilePointerEx,
as we no longer need to support Windows XP

12 days agoMerge pull request #3062 from tosanjay/7zip-file-new-utf16name-leak
Dustin L. Howett [Sun, 24 May 2026 17:43:52 +0000 (12:43 -0500)] 
Merge pull request #3062 from tosanjay/7zip-file-new-utf16name-leak

7zip writer: free file->utf16name on symlink UTF-8 conversion failure

12 days agoMerge pull request #3057 from i1011/mtree-null-deref-fix
Dustin L. Howett [Sun, 24 May 2026 17:43:25 +0000 (12:43 -0500)] 
Merge pull request #3057 from i1011/mtree-null-deref-fix

mtree: Fix null dereference for some corner cases:

- a symlink whose target is never set
- emitting a root directory entry that is actually a file

12 days agoMerge pull request #3071 from stoeckmann/rar5_doublefree
Dustin L. Howett [Sun, 24 May 2026 17:43:00 +0000 (12:43 -0500)] 
Merge pull request #3071 from stoeckmann/rar5_doublefree

rar5: Avoid dangling pointers in init_unpack

12 days agoMerge pull request #3064 from i1011/version-details-fix
Dustin L. Howett [Sun, 24 May 2026 17:39:08 +0000 (12:39 -0500)] 
Merge pull request #3064 from i1011/version-details-fix

Fix libattr version returned in archive_version_details, as well as a leak.

12 days agorar5: Avoid dangling pointers in init_unpack 3071/head
Tobias Stoeckmann [Sun, 24 May 2026 13:06:06 +0000 (15:06 +0200)] 
rar5: Avoid dangling pointers in init_unpack

If init_unpack fails to allocate memory for given window size, a
dangling pointer can lead to an eventual double free.

Resolves #3069.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agomtree: Root entry '.' must be directory 3057/head
i1011 [Wed, 20 May 2026 16:44:39 +0000 (00:44 +0800)] 
mtree: Root entry '.' must be directory

13 days agomtree: Assign empty path to symlink if undefined
i1011 [Wed, 20 May 2026 16:43:36 +0000 (00:43 +0800)] 
mtree: Assign empty path to symlink if undefined

13 days agoAdd two testcases for mtree null deref
i1011 [Sun, 24 May 2026 11:41:16 +0000 (19:41 +0800)] 
Add two testcases for mtree null deref

13 days agoMerge pull request #3051 from stoeckmann/compress_debug
Tobias Stoeckmann [Sun, 24 May 2026 08:15:35 +0000 (10:15 +0200)] 
Merge pull request #3051 from stoeckmann/compress_debug

compress: Remove harmful "dead" code

13 days agoMerge pull request #3052 from stoeckmann/tar_wempty
Tobias Stoeckmann [Sun, 24 May 2026 08:14:50 +0000 (10:14 +0200)] 
Merge pull request #3052 from stoeckmann/tar_wempty

tar: Fix OOB with empty wide character directory names

13 days agoMerge pull request #3035 from stoeckmann/acl_string
Tobias Stoeckmann [Sun, 24 May 2026 08:14:11 +0000 (10:14 +0200)] 
Merge pull request #3035 from stoeckmann/acl_string

acl: Simplify string creation

13 days agoMerge pull request #3041 from stoeckmann/xar_fflags
Tobias Stoeckmann [Sun, 24 May 2026 08:13:34 +0000 (10:13 +0200)] 
Merge pull request #3041 from stoeckmann/xar_fflags

xar: Fix writer OOB accesses with fflags

13 days agoutil: Fix libattr version returned in archive_version_details 3064/head
i1011 [Sun, 24 May 2026 07:22:26 +0000 (15:22 +0800)] 
util: Fix libattr version returned in archive_version_details

Also, add missing init=1 so that the version string
initialization/allocation only runs on the first call.

13 days agoMerge pull request #3060 from stoeckmann/xar_free
Dustin L. Howett [Sun, 24 May 2026 06:19:12 +0000 (01:19 -0500)] 
Merge pull request #3060 from stoeckmann/xar_free

xar: fix fflags_text leak in file_free

2 weeks ago 7zip writer: free file->utf16name on symlink UTF-8 conversion failure 3062/head
SanjayR [Fri, 22 May 2026 05:36:50 +0000 (11:06 +0530)] 
  7zip writer: free file->utf16name on symlink UTF-8 conversion failure

  file_new() at archive_write_set_format_7zip.c:1688 calls free(file)
  on the symlink-UTF8-failure branch, leaving file->utf16name
  (allocated at line 1666) leaked. The two earlier free(file) calls
  in this function (lines 1656, 1668) are correct because they happen
  BEFORE utf16name is allocated, but the third one happens after.

  The rest of the function uses file_free() on every other
  post-utf16name error path; file_free() does free(file->utf16name)
  followed by free(file), which is the cleanup convention. Replacing
  free(file) with file_free(file) makes the symlink-error branch
  consistent with everything else.

  Reproduces with bsdtar in a non-UTF-8 locale with a non-UTF-8
  symlink target:
      ln -s "$(printf 'broken_\\xff\\xfe_link')" sym
      LC_ALL=C ASAN_OPTIONS=detect_leaks=1 \
        bsdtar --format=7zip -cf out.7z sym
  => LeakSanitizer: 30-48 byte direct leak; allocation site is
     file_new (archive_write_set_format_7zip.c:1666).

  Equivalent trigger: any libarchive caller that sets AE_IFLNK
  filetype on an entry without ever calling
  archive_entry_set_symlink() (then archive_entry_symlink_utf8()
  returns NULL and the error branch fires).

  Code unchanged since the 7zip writer's introduction; no existing
  test exercises this error path.

  Identified by Neurolog, a code-analysis tool the reporter is
  developing that combines Souffle Datalog with LLM-assisted fact
  extraction. The reproducer was separately validated under LeakSanitizer
  against current master.

2 weeks agoxar: fix fflags_text leak in file_free 3060/head
Sanjay Rawat [Thu, 21 May 2026 21:51:09 +0000 (23:51 +0200)] 
xar: fix fflags_text leak in file_free

file_free() releases pathname, symlink, uname, gname, and hardlink but
omits fflags_text. When a XAR archive describes a file with <flags> or
<ext2> children (e.g. <SystemNoUnlink/>, <Compress/>), xml_parse_file_flags
/ xml_parse_file_ext2 populate xar_file->fflags_text via archive_strcat,
which heap-allocates. The buffer leaks on every file_free().

Reproduces with ASan+LSan via the bundled bsdtar:
  bsdtar -tvf <xar-with-flags>
=> Direct leak of N bytes ... archive_strcat ... xml_parse_file_flags

Same shape as commit 6767cbe3 ("Free XAR xattr fstype metadata"), which
fixed the analogous miss in xattr_free().

Existing release of fflags_text in archive_string_free is a no-op when
the field was never populated (.s == NULL, free(NULL) is safe), so the
patch is harmless on the non-flags path.

Resolves #3058.

2 weeks agoMerge pull request #3056 from markjdb/master
Tim Kientzle [Wed, 20 May 2026 22:57:07 +0000 (15:57 -0700)] 
Merge pull request #3056 from markjdb/master

libarchive: Force GNU iconv compatibility on FreeBSD

2 weeks agoMerge pull request #3054 from i1011/add-filter-mismatch-fix
Tim Kientzle [Wed, 20 May 2026 22:55:18 +0000 (15:55 -0700)] 
Merge pull request #3054 from i1011/add-filter-mismatch-fix

filter: Fix mismatched filter function dispatch table entry in archive_write_add_filter.c

2 weeks agolibarchive: Force GNU iconv compatibility on FreeBSD 3056/head
Mark Johnston [Wed, 20 May 2026 16:39:40 +0000 (16:39 +0000)] 
libarchive: Force GNU iconv compatibility on FreeBSD

When libarchive is compiled with FreeBSD's native iconv instead of
libiconv, as happens with libarchive in the base system, we need to
configure iconv(3) to handle invalid sequences by returning -1, as
iconv_strncat_in_locale() assumes GNU iconv semantics.

2 weeks agocpio: Fix UAF in error path 3055/head
Sanjay Rawat [Wed, 20 May 2026 16:09:40 +0000 (18:09 +0200)] 
cpio: Fix UAF in error path

Add entry only after its full initialization into list. Otherwise the
error handling of a failing strdup would have to unlink the entry again.

Fixes: 16ad9310733e ("cpio reader: Validate pathname in record_hardlink")
Resolves #3053.

2 weeks agofilter: Fix mismatched add_filter table entry 3054/head
i1011 [Wed, 20 May 2026 13:18:35 +0000 (21:18 +0800)] 
filter: Fix mismatched add_filter table entry

The integer-code dispatch table in archive_write_add_filter() maps
ARCHIVE_FILTER_LZOP to the function pointer archive_write_add_filter_lzip
(the lzip filter setter) instead of archive_write_add_filter_lzop.

2 weeks agoAdd test for filter dispatch in archive_write_add_filter.c
i1011 [Wed, 20 May 2026 12:56:40 +0000 (20:56 +0800)] 
Add test for filter dispatch in archive_write_add_filter.c

Modified from test_archive_write_add_filter_by_name.c

2 weeks agotar: Fix empty wide character string handling 3052/head
Tobias Stoeckmann [Tue, 19 May 2026 19:16:24 +0000 (21:16 +0200)] 
tar: Fix empty wide character string handling

Apply the same fix as done in commit
c246ec5d058a3f70a2d3fb765f92fe9db77b25df for non-wide character
strings.

Without this, empty strings lead to out of boundary read accesses.

Resolves #3046.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agotar: Check empty dir name handling
Tobias Stoeckmann [Tue, 19 May 2026 19:15:01 +0000 (21:15 +0200)] 
tar: Check empty dir name handling

Make sure that empty wide character names do not lead to out of boundary
accesses.

Reported by shura-turtle.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocompress: Remove harmful "dead" code 3051/head
Tobias Stoeckmann [Tue, 19 May 2026 15:32:26 +0000 (17:32 +0200)] 
compress: Remove harmful "dead" code

The debug_buff array is populated but never read. If multiple threads
process compress streams, they access the same index variable, which
could lead to out of boundary writes.

Delete the debug code to fix this issue.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agobzip2: Support large in-memory archives 3050/head
Tobias Stoeckmann [Tue, 19 May 2026 15:24:01 +0000 (17:24 +0200)] 
bzip2: Support large in-memory archives

If an archive has more than UINT_MAX (4 GB) bytes available, the bzip2
filter will enter an endless loop.

Apply same logic of gzip filter from commit
256c71ad4eee22a7dac2f13df1e20d85717cbdf6.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoMerge pull request #3027 from stoeckmann/xar_debug
Tobias Stoeckmann [Tue, 19 May 2026 15:19:06 +0000 (17:19 +0200)] 
Merge pull request #3027 from stoeckmann/xar_debug

xar: Do not modify variables in DEBUG block

2 weeks agoMerge pull request #3033 from stoeckmann/filter_strcpy
Tobias Stoeckmann [Tue, 19 May 2026 15:18:05 +0000 (17:18 +0200)] 
Merge pull request #3033 from stoeckmann/filter_strcpy

filter: Remove unneeded strcpy calls

2 weeks agoMerge pull request #3036 from stoeckmann/cmdline_strdup
Tobias Stoeckmann [Tue, 19 May 2026 15:17:42 +0000 (17:17 +0200)] 
Merge pull request #3036 from stoeckmann/cmdline_strdup

cmdline: Use free+strdup instead of realloc+strcpy

2 weeks agoMerge pull request #3037 from stoeckmann/strmode_strcpy
Tobias Stoeckmann [Tue, 19 May 2026 15:17:24 +0000 (17:17 +0200)] 
Merge pull request #3037 from stoeckmann/strmode_strcpy

strmode: Remove strcpy usage

2 weeks agoMerge pull request #3044 from stoeckmann/util_windows_toctou
Tobias Stoeckmann [Tue, 19 May 2026 15:16:28 +0000 (17:16 +0200)] 
Merge pull request #3044 from stoeckmann/util_windows_toctou

util: Fix GetTempPathW TOCTOU race condition

2 weeks agoMerge pull request #3043 from datauwu/cpio-patch
Dustin L. Howett [Sun, 17 May 2026 20:24:24 +0000 (13:24 -0700)] 
Merge pull request #3043 from datauwu/cpio-patch

2 weeks agoutil: Fix GetTempPathW TOCTOU race condition 3044/head
Tobias Stoeckmann [Sun, 17 May 2026 13:49:57 +0000 (15:49 +0200)] 
util: Fix GetTempPathW TOCTOU race condition

Currently, the code calls GetTempPathW to figure out required size for a
buffer larger enough to contain the temporary directory path, allocates
the memory, and then calls GetTempPathW again to populate the memory.

Since libarchive is designed with multi-threading in mind, the worst
situation would be that another thread modifies the environment variable
between these two calls.

Use a buffer of MAX_PATH + 1 (261) to basically cover all regular
situations. If long paths are enabled, reallocate until enough bytes
were available (32 kb is maximum) without another thread intefering.
Realistically, this will happen only once.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocpio: reject oversized pathnames before read-ahead 3043/head
datauwu [Sun, 17 May 2026 07:34:15 +0000 (15:34 +0800)] 
cpio: reject oversized pathnames before read-ahead

Reject malformed CPIO entries whose pathname field exceeds 1 MiB before asking the read-ahead layer to satisfy the padded pathname length.

This prevents newc archives with attacker-controlled c_namesize values from forcing large metadata read-ahead and pathname allocation during archive listing. Add a regression test that fails on the unpatched reader and passes once the cap is enforced.

Signed-off-by: datauwu <datauwu@users.noreply.github.com>
2 weeks agoMerge commit from fork
Tobias Stoeckmann [Sun, 17 May 2026 08:21:08 +0000 (10:21 +0200)] 
Merge commit from fork

read: Fix memory corruption on filtered multi-volume archives

2 weeks agoMerge pull request #3040 from kientzle/fix/unchecked-alloc
Tim Kientzle [Sat, 16 May 2026 22:04:07 +0000 (15:04 -0700)] 
Merge pull request #3040 from kientzle/fix/unchecked-alloc

Fix a number of unchecked memory allocations

2 weeks agoxar: Fix OOB accesses with fflags 3041/head
Tobias Stoeckmann [Sat, 16 May 2026 19:21:36 +0000 (21:21 +0200)] 
xar: Fix OOB accesses with fflags

If multiple fflags are added to archive, a stack out of boundary is
triggered due to insufficient array allocation.

Also, if flags with long names are supplied, an out of boundary read can
occur.

Resolves GHSA-wfvr-54j8-47r9.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoxar: Add fflag regression test
Tobias Stoeckmann [Sat, 16 May 2026 19:19:08 +0000 (21:19 +0200)] 
xar: Add fflag regression test

It is possible to trigger an out of boundary stack write and out of
boundary reads with fflags.

Based on proof of concept reported by Cris Jacob Maamor.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoMerge pull request #3038 from stoeckmann/tar_util_string
Tobias Stoeckmann [Sat, 16 May 2026 19:40:12 +0000 (21:40 +0200)] 
Merge pull request #3038 from stoeckmann/tar_util_string

tar: Improve string safety in list_item_verbose

2 weeks agoacl: Do not count entries during string creation 3035/head
Tobias Stoeckmann [Sat, 16 May 2026 13:09:59 +0000 (15:09 +0200)] 
acl: Do not count entries during string creation

It is only relevant to know if a separator has to be inserted. This can
be simplified by only checking if string already contains characters.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoacl: Use archive_string/archive_wstring
Tobias Stoeckmann [Sat, 16 May 2026 13:06:21 +0000 (15:06 +0200)] 
acl: Use archive_string/archive_wstring

Since libarchive already contains infrastructure to safely work with
strings, use it instead of manually constructing strings.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoFix unchecked malloc result in XXH32_init 3040/head
Tim Kientzle [Sat, 16 May 2026 17:04:51 +0000 (10:04 -0700)] 
Fix unchecked malloc result in XXH32_init

If XXH_malloc fails, state would be NULL and passed directly to
XXH32_resetState, causing a NULL dereference.

2 weeks agoFix unchecked strdup result in __archive_write_program_allocate
Tim Kientzle [Sat, 16 May 2026 17:04:38 +0000 (10:04 -0700)] 
Fix unchecked strdup result in __archive_write_program_allocate

If strdup fails, program_name would be NULL and later use could crash.
Free data and return NULL on allocation failure.

2 weeks agoFix unchecked calloc results in init_unpack (rar5)
Tim Kientzle [Sat, 16 May 2026 17:04:24 +0000 (10:04 -0700)] 
Fix unchecked calloc results in init_unpack (rar5)

window_buf and filtered_buf were allocated via calloc without checking
for NULL. Change init_unpack to return int and propagate ARCHIVE_FATAL
on allocation failure to the caller.

2 weeks agoFix unchecked calloc result in make_table (rar)
Tim Kientzle [Sat, 16 May 2026 17:03:31 +0000 (10:03 -0700)] 
Fix unchecked calloc result in make_table (rar)

If calloc fails, code->table would be NULL and passed directly to
make_table_recurse, causing a NULL dereference.

2 weeks agoFix unchecked calloc result in tree_open
Tim Kientzle [Sat, 16 May 2026 17:03:11 +0000 (10:03 -0700)] 
Fix unchecked calloc result in tree_open

If calloc fails, t would be NULL and immediately dereferenced.
Return NULL on allocation failure.

2 weeks agoFix unchecked calloc result in tree_push
Tim Kientzle [Sat, 16 May 2026 17:02:57 +0000 (10:02 -0700)] 
Fix unchecked calloc result in tree_push

If calloc fails, te would be NULL and immediately dereferenced.
Return early on allocation failure.

2 weeks agoFix unchecked malloc result in read_reparse_data
Tim Kientzle [Sat, 16 May 2026 17:02:30 +0000 (10:02 -0700)] 
Fix unchecked malloc result in read_reparse_data

If malloc fails, indata would be NULL and passed directly to
DeviceIoControl, causing undefined behavior.

2 weeks agoMerge pull request #3032 from stoeckmann/dotdot
Tim Kientzle [Sat, 16 May 2026 16:39:31 +0000 (09:39 -0700)] 
Merge pull request #3032 from stoeckmann/dotdot

Port iso9660 fix for `..` (dot dot) path normalization to mtree and xar

2 weeks agotar: Improve string safety in list_item_verbose 3038/head
Tobias Stoeckmann [Sat, 16 May 2026 13:40:13 +0000 (15:40 +0200)] 
tar: Improve string safety in list_item_verbose

The strcpy and sprintf functions are generally hard to reason about.
While they are safe in this context, I think, it's easy to refactor the
code to avoid them completely.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agostrmode: Remove strcpy usage 3037/head
Tobias Stoeckmann [Sat, 16 May 2026 13:33:23 +0000 (15:33 +0200)] 
strmode: Remove strcpy usage

The code can be simplified to avoid strcpy usage. While not exactly a
much safer approach by manually adjusting characters in a string, this
attempt reduces size of libarchive and avoids unneeded copy operations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocmdline: Use free+strdup instead of realloc+strcpy 3036/head
Tobias Stoeckmann [Sat, 16 May 2026 13:25:53 +0000 (15:25 +0200)] 
cmdline: Use free+strdup instead of realloc+strcpy

The cmdline_set_path function contains logic to reallocate memory of
command path and copy a new value into it.

Inline a simpler free+strdup alternative into __archive_cmdline_parse.
Since the function is always called with empty data, free could be
removed as well. I've kept it that way just to make sure that it's 100 %
compatible with previous code.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoread: Fix memory corruption in client_switch_proxy
Tobias Stoeckmann [Fri, 15 May 2026 15:08:55 +0000 (17:08 +0200)] 
read: Fix memory corruption in client_switch_proxy

Switching a multi-volume archive file with another active filter, e.g.
decompression, can lead to memory corruption due to modifying the wrong
private data (self->data).

Use highest upstream filter to replace the correct private data.

Resolves GHSA-qf8j-cq3h-8m2m.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoread: Add multi-volume regression test
Tobias Stoeckmann [Fri, 15 May 2026 15:07:27 +0000 (17:07 +0200)] 
read: Add multi-volume regression test

Check that no memory corruption occurs when switching files which are
decompressed through filters.

Test case supplied by Stuart Wallace.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoread: Simplify client_switch_proxy
Tobias Stoeckmann [Fri, 15 May 2026 15:04:32 +0000 (17:04 +0200)] 
read: Simplify client_switch_proxy

Use a dedicated variable for archive instead of referencing
self->archive again and again. Also, inline client_open_proxy.

While at it, fix space intendation.

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agofilter: Remove unneeded strcpy calls 3033/head
Tobias Stoeckmann [Thu, 14 May 2026 18:42:13 +0000 (20:42 +0200)] 
filter: Remove unneeded strcpy calls

No need to copy these values on stack. Just use them on heap directly.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agomtree: Fix dot dot handling 3032/head
Tobias Stoeckmann [Thu, 14 May 2026 18:23:08 +0000 (20:23 +0200)] 
mtree: Fix dot dot handling

Port iso9660 dot dot handling over to mtree.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoxar: Fix dot dot handling
Tobias Stoeckmann [Thu, 14 May 2026 18:22:48 +0000 (20:22 +0200)] 
xar: Fix dot dot handling

Port iso9660 dot dot handling over to xar.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agomtree: Add dot dot regression test
Tobias Stoeckmann [Thu, 14 May 2026 18:22:10 +0000 (20:22 +0200)] 
mtree: Add dot dot regression test

Check if resolving dot dot does work as expected.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoxar: Add dot dot regression test
Tobias Stoeckmann [Thu, 14 May 2026 18:20:21 +0000 (20:20 +0200)] 
xar: Add dot dot regression test

Check if resolving dot dot does work as expected.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #3028 from br0nzu/xar-fstype-cleanup
Tim Kientzle [Thu, 14 May 2026 02:24:27 +0000 (19:24 -0700)] 
Merge pull request #3028 from br0nzu/xar-fstype-cleanup

Free XAR xattr fstype metadata during cleanup

3 weeks agoMerge pull request #3030 from stoeckmann/xar_atol
Tim Kientzle [Thu, 14 May 2026 01:51:45 +0000 (18:51 -0700)] 
Merge pull request #3030 from stoeckmann/xar_atol

xar: Avoid integer overflows in number parsers

3 weeks agoMerge pull request #3029 from stoeckmann/iso_memleak
Tim Kientzle [Thu, 14 May 2026 01:51:29 +0000 (18:51 -0700)] 
Merge pull request #3029 from stoeckmann/iso_memleak

iso9660: Fix memory leaks on error paths

3 weeks agoxar: Handle integer overflows in atou64 3030/head
Tobias Stoeckmann [Wed, 13 May 2026 17:05:48 +0000 (19:05 +0200)] 
xar: Handle integer overflows in atou64

Parsing a string into an integer also means that boundary checks have to
be performed. Check within atou64 as well as outside by verifying that
subsequent casts won't truncate numbers.

Use error handling available by callers.

Reported by Muhammed Hussein.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>