]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
4 weeks agoFix typos in comments
Tobias Stoeckmann [Sun, 31 May 2026 09:06:30 +0000 (11:06 +0200)] 
Fix typos in comments

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks ago7zip: Extend support for filtered input 3099/head
Tobias Stoeckmann [Sun, 31 May 2026 13:40:23 +0000 (15:40 +0200)] 
7zip: Extend support for filtered input

The 7-ZIP archives written by libarchive can be streamed. Support such
archives by using a fallback if seek is not supported: As long as the
target position is somewhere ahead in stream, consume bytes until the
position is reached.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agofilters: Simplify __archive_read_filter_ahead use 3098/head
Tobias Stoeckmann [Sun, 31 May 2026 09:22:59 +0000 (11:22 +0200)] 
filters: Simplify __archive_read_filter_ahead use

The third argument (available bytes) is not always evaluated. It is
perfectly fine to pass a NULL argument if it's not needed.

Also, some checks of the third argument can be removed, because in case
of an error (< 0) or in case of end of stream (0) the return value is
NULL anyway. If a NULL check is already in place, just use it.

Simplifies code audits because it's obvious that the available bytes are
not needed within the function if they are never stored.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agocpio: Improve afio header detection 3095/head
Tobias Stoeckmann [Sat, 30 May 2026 19:09:28 +0000 (21:09 +0200)] 
cpio: Improve afio header detection

Do not assume that enough bytes will be provided by filter if not
explicitly requested. The requested size is 76, but some checks expect
116 bytes. If these were not supplied by filter, th afio header
detection erroneously skips headers which otherwise could be found.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agocpio: Prevent signed integer overflow
Tobias Stoeckmann [Sat, 30 May 2026 19:05:02 +0000 (21:05 +0200)] 
cpio: Prevent signed integer overflow

If enough bytes have to be skipped, a signed integer overflow could
occur (most realistically on 32 bit systems). Use an unsigned type,
which could still overflow but has only negative impact on diagnostic
warning message.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agocpio: Add afio header split test
Tobias Stoeckmann [Fri, 29 May 2026 21:36:44 +0000 (23:36 +0200)] 
cpio: Add afio header split test

Verify that afio headers are detected even on unfortunate filter read
splits, i.e. when magic is found but rest of header has yet to be
retrieved.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agoxar: Remove redundant decrement in xar_finish_entry 3094/head
i1011 [Sat, 30 May 2026 17:23:39 +0000 (01:23 +0800)] 
xar: Remove redundant decrement in xar_finish_entry

4 weeks agoxar: Add test for redundant decrement in xar_finish_entry
i1011 [Sat, 30 May 2026 17:22:32 +0000 (01:22 +0800)] 
xar: Add test for redundant decrement in xar_finish_entry

4 weeks agorar5: consume unconsumed block bytes before ARCHIVE_RETRY 3091/head
yPin9 [Sat, 30 May 2026 12:19:25 +0000 (20:19 +0800)] 
rar5: consume unconsumed block bytes before ARCHIVE_RETRY

process_base_block() returned ARCHIVE_RETRY for HEAD_MAIN (and
HFL_SKIP_IF_UNKNOWN) blocks without consuming the body bytes the
sub-parser did not read. rar5_read_header() then re-parsed the same
region, turning an O(1) skip into O(N) and letting a crafted RAR5 file
stall the reader (GHSA-9h2c-464f-j3hj).

Record the block body start and skip any unconsumed bytes through a
small helper rar5_skip_remaining_block() before returning ARCHIVE_RETRY.

Add two regression tests derived from test_read_format_rar5_stored, each
with extra unread bytes appended to a no-data block's body (HEAD_MAIN and
an unknown HFL_SKIP_IF_UNKNOWN block); both fail on master and pass with
the fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 weeks agoMerge pull request #3088 from mostynb/improve_bsdtar_subst_error_messages
Dustin L. Howett [Fri, 29 May 2026 18:48:14 +0000 (13:48 -0500)] 
Merge pull request #3088 from mostynb/improve_bsdtar_subst_error_messages

tar: Improve -s Invalid replacement string error messages

4 weeks 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>
4 weeks 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>
4 weeks 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>
4 weeks agoMerge pull request #3085 from stoeckmann/gzip_check
Tobias Stoeckmann [Fri, 29 May 2026 16:00:49 +0000 (18:00 +0200)] 
Merge pull request #3085 from stoeckmann/gzip_check

gzip: Support more large in-memory archives

4 weeks agoMerge pull request #3092 from vmihalis/https-config-fetch
Tim Kientzle [Fri, 29 May 2026 16:00:39 +0000 (09:00 -0700)] 
Merge pull request #3092 from vmihalis/https-config-fetch

build: fetch config.guess/config.sub over HTTPS

4 weeks agobuild: fetch config.guess/config.sub over HTTPS in release Dockerfile 3092/head
Michalis Vasileiadis [Fri, 29 May 2026 13:30:38 +0000 (21:30 +0800)] 
build: fetch config.guess/config.sub over HTTPS in release Dockerfile

Switch the config.guess/config.sub ADD fetches from http:// to https://
(CWE-494).

4 weeks agobuild: fetch config.guess/config.sub over HTTPS in makerelease.sh
Michalis Vasileiadis [Fri, 29 May 2026 13:30:34 +0000 (21:30 +0800)] 
build: fetch config.guess/config.sub over HTTPS in makerelease.sh

Switch the release-time config.guess/config.sub fetches from http:// to
https:// and add -fsSL so a failed fetch errors out instead of writing an
error page into the helper script (CWE-494).

4 weeks agoRemove Cirrus CI setup, it is shutting down in a few days 3089/head
Mostyn Bramley-Moore [Thu, 28 May 2026 22:45:38 +0000 (00:45 +0200)] 
Remove Cirrus CI setup, it is shutting down in a few days

https://circleci.com/blog/cirrus-ci-alternative/
> On April 7, the Cirrus Labs team announced they are joining OpenAI.
> As a result, Cirrus CI will stop running jobs on June 1, 2026.

4 weeks agotar: Improve -s Invalid replacement string error messages 3088/head
Mostyn Bramley-Moore [Thu, 28 May 2026 22:28:08 +0000 (00:28 +0200)] 
tar: Improve -s Invalid replacement string error messages

We can add a bit more context here, to make the error easier to understand.

4 weeks 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

4 weeks 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

4 weeks 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>
4 weeks 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

4 weeks 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

4 weeks agogzip: Support more large in-memory archives 3085/head
Tobias Stoeckmann [Wed, 27 May 2026 20:40:11 +0000 (22:40 +0200)] 
gzip: Support more large in-memory archives

Apply same logic of gzip_filter_read from commit
256c71ad4eee22a7dac2f13df1e20d85717cbdf6
to consumer_header, which contains the identical issue.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks 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>
4 weeks 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

4 weeks 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>
4 weeks agobzip2: Remove dead code 3082/head
Tobias Stoeckmann [Wed, 27 May 2026 19:19:09 +0000 (21:19 +0200)] 
bzip2: Remove dead code

The check for end of file (avail == 0) happens after the check for a
NULL return value of __archive_read_filter_ahead.

Remove it, because at this stage, it's definitely truncated, not just
end of file.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agotests: Skip checks on low memory systems 3081/head
Tobias Stoeckmann [Wed, 27 May 2026 18:49:29 +0000 (20:49 +0200)] 
tests: Skip checks on low memory systems

If not enough memory is available, skip tests. This can happen on 32 bit
systems with ASAN enabled. While these tests run perfectly fine if run
directly with libarchive_test, the test harness fails with eventual NULL
pointer dereferences, since these assert-checks do not stop processing.

Happens with lzma and xz and compression level 9.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks 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>
4 weeks 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

4 weeks 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

4 weeks 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

4 weeks 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

4 weeks 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.

4 weeks 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

4 weeks 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

4 weeks 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.

4 weeks 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

4 weeks 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

4 weeks 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>
4 weeks 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>
4 weeks 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

4 weeks 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.

4 weeks 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.

4 weeks 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>
4 weeks 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

4 weeks 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

4 weeks 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

5 weeks 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.

5 weeks 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>
5 weeks agolz4/zstd: Fix integer overflows while bidding 3073/head
Tobias Stoeckmann [Mon, 25 May 2026 19:09:10 +0000 (21:09 +0200)] 
lz4/zstd: Fix integer overflows while bidding

The C standard dictates that integer promotion increases data types up
to int or the largest argument in arithmetic.

This becomes problematic in `offset_in_buffer += 4 + frame_data_size`
which effectively is `size_t += int + uint32_t`.

If frame_data_size is UINT32_MAX, adding 4 overflows before the
overflown value is added to size_t.

On 32 bit systems, this can easily lead to an endless loop or out of
boundary access.

Fix this by properly checking if integer overflows would occur.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 weeks agozstd: Check for endless loop on 32 bit systems
Tobias Stoeckmann [Mon, 25 May 2026 18:59:44 +0000 (20:59 +0200)] 
zstd: Check for endless loop on 32 bit systems

It is possible to trigger an endless loop on 32 bit systems due to
a triggerable integer overflow.

Add a regression test for this.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 weeks agolz4/zstd: Use correct data types while bidding
Tobias Stoeckmann [Mon, 25 May 2026 18:56:12 +0000 (20:56 +0200)] 
lz4/zstd: Use correct data types while bidding

Use size_t where size_t arguments are expected (and cast avail to size_t
because we know at this point that it cannot be negative).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 weeks agolz4/zstd: Apply style guide in bidding function
Tobias Stoeckmann [Mon, 25 May 2026 18:52:01 +0000 (20:52 +0200)] 
lz4/zstd: Apply style guide in bidding function

Use C comments, define variables at start of block, keep 80 chars per
line. While at it, turn a few variables const to clarify that they do
not change.

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 weeks 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>
5 weeks 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.

5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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.

5 weeks 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>
5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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

5 weeks 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.

5 weeks 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

5 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.

5 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.

5 weeks agoiso9660: avoid negative duplicate suffix offsets 3045/head
datauwu [Thu, 21 May 2026 02:55:26 +0000 (10:55 +0800)] 
iso9660: avoid negative duplicate suffix offsets

Avoid passing negative suffix offsets to the duplicate identifier
resolver. Clamp them where ISO9660 and Joliet identifiers decide
where the duplicate suffix should be written.

5 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

5 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

5 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.

5 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.

5 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.

5 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

5 weeks agoiso9660: test duplicate Joliet identifier truncation
datauwu [Wed, 20 May 2026 01:36:20 +0000 (09:36 +0800)] 
iso9660: test duplicate Joliet identifier truncation

Add a test for ISO9660 entries whose Joliet identifiers collide
after default identifier truncation. The writer should resolve
the duplicate identifiers successfully when the archive is closed.

5 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>
5 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>
5 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>
5 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>
5 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

5 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

5 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

5 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

5 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

5 weeks agorar: reset low-distance state for new LZ tables 3048/head
Wei-Cheng Pan [Tue, 19 May 2026 06:55:55 +0000 (15:55 +0900)] 
rar: reset low-distance state for new LZ tables

Low-distance repeat state is scoped to the current RAR3 LZ table. Reusing it after a new table starts can make the next match use the wrong offset, producing incorrect output and a file CRC error.

Reset lastlowoffset and numlowoffsetrepeats when parsing a new LZ table. Add a small handcrafted RAR3 fixture that leaves a low-distance repeat pending, switches tables, and verifies the decoded bytes after the boundary.

5 weeks agorar: skip NEWSUB payloads without size cap 3047/head
Wei-Cheng Pan [Tue, 19 May 2026 06:41:44 +0000 (15:41 +0900)] 
rar: skip NEWSUB payloads without size cap

RAR3 recovery records can be stored as NEWSUB RR blocks with payloads larger than the old 1 MiB extended-header limit. These records are metadata-only for this reader, so after validating the header and guarding against header-size plus payload-size overflow, consume the remaining header bytes and payload instead of rejecting the archive.

Add a reference archive with a NEWSUB RR payload just over 1 MiB, and keep the malformed huge-size case covering the overflow/truncation path.

6 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

6 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>
6 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>
6 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

6 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

6 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>