]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
5 days ago7zip: Support old zstd versions as well 3102/head
Tobias Stoeckmann [Mon, 1 Jun 2026 18:15:31 +0000 (20:15 +0200)] 
7zip: Support old zstd versions as well

Use ZSTD_DStream only if it's available, which should always be the
case.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 days ago7zip: only fall back to 7Z_ZSTD if we can actually use zstd
Dustin L. Howett [Mon, 1 Jun 2026 17:38:07 +0000 (13:38 -0400)] 
7zip: only fall back to 7Z_ZSTD if we can actually use zstd

Without this fix, the 7zip writer will fall back to zstd (when it is the
last available option) even if it could not be linked, then fail at
runtime with an unexpected error message.

5 days ago7zip: fix -Wunused-function if zstd.h exists but zstd can't be linked
Dustin L. Howett [Thu, 28 May 2026 22:40:05 +0000 (17:40 -0500)] 
7zip: fix -Wunused-function if zstd.h exists but zstd can't be linked

5 days agoMerge pull request #3094 from i1011/xar-redundant-dec-fix
Dustin L. Howett [Mon, 1 Jun 2026 11:50:50 +0000 (06:50 -0500)] 
Merge pull request #3094 from i1011/xar-redundant-dec-fix

5 days agoMerge pull request #3089 from mostynb/remove_cirrus_ci
Martin Matuška [Mon, 1 Jun 2026 07:58:42 +0000 (09:58 +0200)] 
Merge pull request #3089 from mostynb/remove_cirrus_ci

Remove Cirrus CI setup, it is shutting down in a few days

5 days agoMerge pull request #3093 from stoeckmann/lz4_skip
Martin Matuška [Mon, 1 Jun 2026 07:55:02 +0000 (09:55 +0200)] 
Merge pull request #3093 from stoeckmann/lz4_skip

lz4: Improve truncated input stream detection

5 days agoMerge pull request #3095 from stoeckmann/afio_header
Martin Matuška [Mon, 1 Jun 2026 07:54:26 +0000 (09:54 +0200)] 
Merge pull request #3095 from stoeckmann/afio_header

cpio: Improve afio header detection

5 days agoMerge pull request #3096 from stoeckmann/filters_comments
Martin Matuška [Mon, 1 Jun 2026 07:53:36 +0000 (09:53 +0200)] 
Merge pull request #3096 from stoeckmann/filters_comments

filters: Update comments

5 days agoMerge pull request #3097 from stoeckmann/typos
Martin Matuška [Mon, 1 Jun 2026 07:53:20 +0000 (09:53 +0200)] 
Merge pull request #3097 from stoeckmann/typos

Fix typos in comments and error message

5 days agoMerge pull request #3099 from stoeckmann/7zip_seek
Martin Matuška [Mon, 1 Jun 2026 07:51:32 +0000 (09:51 +0200)] 
Merge pull request #3099 from stoeckmann/7zip_seek

7zip: Extend support for filtered input

5 days agoMerge pull request #3100 from stoeckmann/lz4_xxh32
Martin Matuška [Mon, 1 Jun 2026 07:50:34 +0000 (09:50 +0200)] 
Merge pull request #3100 from stoeckmann/lz4_xxh32

lz4: Check `XXH32_init` result

6 days agolz4: Check XXH32_init result 3100/head
Tobias Stoeckmann [Sun, 31 May 2026 15:41:41 +0000 (17:41 +0200)] 
lz4: Check XXH32_init result

The XXH32_init function allocates memory. Check if the allocation was
successful and return ARCHIVE_FATAL on error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agofilters: Update comments 3096/head
Tobias Stoeckmann [Sun, 31 May 2026 09:02:55 +0000 (11:02 +0200)] 
filters: Update comments

Some filter comments were not updated when the execution of external
filter programs was introduced.

Sync them with reality, including the actually performed commands.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agoFix typo in manual page 3097/head
Tobias Stoeckmann [Sun, 31 May 2026 15:13:50 +0000 (17:13 +0200)] 
Fix typo in manual page

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agoread: Fix typo in error message
Tobias Stoeckmann [Sun, 31 May 2026 09:06:39 +0000 (11:06 +0200)] 
read: Fix typo in error message

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

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

8 days 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

8 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>
8 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>
8 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 #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

8 days 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

8 days 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).

8 days 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).

9 days 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.

9 days 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.

9 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

9 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

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

9 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

10 days 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>
10 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>
10 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

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

11 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

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

11 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

11 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

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

11 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

11 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

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

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

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

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

11 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

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

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

13 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

13 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

13 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

13 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

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

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