]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
6 weeks agoAdd missing HAVE_STDIO_H cmake check
Tobias Stoeckmann [Mon, 9 Mar 2026 20:00:14 +0000 (21:00 +0100)] 
Add missing HAVE_STDIO_H cmake check

The check is performed by configure, but not with cmake. The
bsdunzip/la_getline.c file checks for presence of this definition.

6 weeks agoMerge pull request #2871 from stoeckmann/archive_options_either
Tim Kientzle [Mon, 16 Mar 2026 02:21:37 +0000 (19:21 -0700)] 
Merge pull request #2871 from stoeckmann/archive_options_either

libarchive: Correctly handle option failures

6 weeks agoMerge pull request #2900 from LoboQ1ng/fix-cab-null-deref
Tim Kientzle [Mon, 16 Mar 2026 01:41:04 +0000 (18:41 -0700)] 
Merge pull request #2900 from LoboQ1ng/fix-cab-null-deref

Fix NULL pointer dereference in CAB parser during skip

6 weeks agoMerge pull request #2903 from ZUENS2020/codex/fix-untar-parseoct-bounds-check
Tim Kientzle [Mon, 16 Mar 2026 01:39:32 +0000 (18:39 -0700)] 
Merge pull request #2903 from ZUENS2020/codex/fix-untar-parseoct-bounds-check

Fix OOB read in contrib/untar.c parseoct()

6 weeks agoMerge pull request #2901 from stoeckmann/cpio_llp64
Tim Kientzle [Mon, 16 Mar 2026 01:39:10 +0000 (18:39 -0700)] 
Merge pull request #2901 from stoeckmann/cpio_llp64

tools: Cast int64_t to long long in printf

6 weeks agoFix NULL pointer dereference in archive_acl_from_text_nl 2905/head
Georgios Patsakas [Thu, 12 Mar 2026 20:24:13 +0000 (22:24 +0200)] 
Fix NULL pointer dereference in archive_acl_from_text_nl

### Summary
This PR fixes a NULL pointer dereference in `archive_acl_from_text_nl()` (located in `archive_acl.c`) that occurs when parsing malformed PAX tar archives containing a short "default" ACL prefix.

### Technical Details
This is a variant of the bug previously fixed in the wide-character version `archive_acl_from_text_w()` via commit 7a6549a6 (Issue #2744).

The vulnerability exists because `st = field[n].start + 1` is calculated before verifying if the field length is zero. In cases of malformed entries, `field[n].start` can be NULL, leading to Undefined Behavior/SIGILL. This patch applies the same logic from the wide-char fix: moving the pointer increment after the length guard.

### Validation
- **Environment:** Ubuntu 24.04, compiled with AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan).
- **Reproduction:** Verified that the minimized PAX tar archive provided in issue #2904 no longer triggers the crash.
- **Regression:** All existing library tests pass.

Closes #2904

6 weeks agoFix OOB read in contrib/untar.c parseoct() 2903/head
ZUENS2020 [Wed, 11 Mar 2026 13:34:58 +0000 (21:34 +0800)] 
Fix OOB read in contrib/untar.c parseoct()

Reported-by: ZUENS2020
7 weeks agotar: print int64_t uid/gid as long long 2901/head
Tobias Stoeckmann [Tue, 10 Mar 2026 19:10:24 +0000 (20:10 +0100)] 
tar: print int64_t uid/gid as long long

On LLP64 systems like Windows 11, overly large uid/gid values would be
truncated.

Same is true on Linux 32 bit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 weeks agocpio: Cast int64_t to long long in printf
Tobias Stoeckmann [Tue, 10 Mar 2026 17:20:40 +0000 (18:20 +0100)] 
cpio: Cast int64_t to long long in printf

LLP64 systems like Windows 11 have a 32 bit long. Cast int64_t to
long long for better output.

Same is true for 32 bit systems.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 weeks agoFix NULL pointer dereference in CAB parser during skip 2900/head
LoboQ1ng [Tue, 10 Mar 2026 17:04:43 +0000 (17:04 +0000)] 
Fix NULL pointer dereference in CAB parser during skip

When parsing a malformed CAB file, the skip routine (cab_checksum_finish) blindly calculated the checksum on an uninitialized cfdata->memimage. This patch adds a NULL check before the checksum calculation and includes a standalone test case with a minimized malformed payload to prevent regressions.

7 weeks agoMerge pull request #2877 from kientzle/kientzle-rar5-loop-bug
Tim Kientzle [Tue, 10 Mar 2026 02:52:31 +0000 (19:52 -0700)] 
Merge pull request #2877 from kientzle/kientzle-rar5-loop-bug

Infinite loop in Rar5 decompression

7 weeks agoReject filters when the block length is nonsensical 2877/head
Tim Kientzle [Mon, 2 Mar 2026 04:24:56 +0000 (20:24 -0800)] 
Reject filters when the block length is nonsensical

Credit: Grzegorz Antoniak @antekone

7 weeks agoInfinite loop in Rar5 decompression
Tim Kientzle [Sun, 1 Mar 2026 18:04:01 +0000 (10:04 -0800)] 
Infinite loop in Rar5 decompression

Found by: Elhanan Haenel

7 weeks agoAdd TODO comment for future error propagation 2897/head
elhananhaenel [Sun, 8 Mar 2026 13:33:50 +0000 (15:33 +0200)] 
Add TODO comment for future error propagation

7 weeks agoFix -Wsign-compare: cast mask+1 to unsigned int 2898/head
elhananhaenel [Sun, 8 Mar 2026 13:29:46 +0000 (15:29 +0200)] 
Fix -Wsign-compare: cast mask+1 to unsigned int

7 weeks agorar: fix LZSS window size mismatch after PPMd block
elhananhaenel [Sat, 7 Mar 2026 20:32:09 +0000 (22:32 +0200)] 
rar: fix LZSS window size mismatch after PPMd block

When a PPMd-compressed block updates dictionary_size, the LZSS window
from a prior block is not reallocated. The allocation guard only checks
if dictionary_size is zero or the window pointer is NULL, not whether
the existing window is large enough. This allows copy_from_lzss_window()
to read past the allocated buffer.

Fix the guard to also check whether the current window is undersized.
Add bounds checks in copy_from_lzss_window() and parse_filter() as
defense in depth.

7 weeks agoiso9660: validate pz_log2_bs in parse_rockridge_ZF1()
elhananhaenel [Sat, 7 Mar 2026 20:14:23 +0000 (22:14 +0200)] 
iso9660: validate pz_log2_bs in parse_rockridge_ZF1()

The zisofs block size exponent (pz_log2_bs) read from the Rock Ridge ZF
extension entry is used directly in shift expressions without validation.
The zisofs specification only permits values 15, 16, or 17 (corresponding
to 32K, 64K, and 128K block sizes).

When pz_log2_bs >= 64 on 64-bit systems (or >= 32 on 32-bit), the
expression (size_t)1UL << pz_log2_bs is undefined behavior per C11
6.5.7. On 32-bit systems, a large exponent also causes the block pointer
allocation size computation (ceil + 1) * 4 to overflow to zero, leading
to a heap buffer overflow write after malloc(0).

Fix: reject any pz_log2_bs outside the range [15, 17] by disabling
zisofs for the entry (file->pz = 0), which prevents the zisofs
decompression path from executing.

Found by fuzzing with ASAN/UBSAN.

7 weeks agoMerge pull request #2896 from kientzle/kientzle-fix-omitted-uu
Tim Kientzle [Sat, 7 Mar 2026 18:53:05 +0000 (10:53 -0800)] 
Merge pull request #2896 from kientzle/kientzle-fix-omitted-uu

Add UU file from #2864 to Makefile.am

7 weeks agoAdd UU file from #2864 to Makefile.am 2896/head
Tim Kientzle [Sat, 7 Mar 2026 18:46:43 +0000 (10:46 -0800)] 
Add UU file from #2864 to Makefile.am

7 weeks agoMerge pull request #2889 from OwenSanzas/fix/linkify-fuzzer-double-free
Tim Kientzle [Sat, 7 Mar 2026 18:29:36 +0000 (10:29 -0800)] 
Merge pull request #2889 from OwenSanzas/fix/linkify-fuzzer-double-free

Fix double-free in libarchive_linkify_fuzzer

7 weeks agoMerge pull request #2864 from vdsilva/patch
Tim Kientzle [Sat, 7 Mar 2026 18:15:44 +0000 (10:15 -0800)] 
Merge pull request #2864 from vdsilva/patch

7zip: Fix SEGV in check_7zip_header_in_sfx via ELF offset validation

7 weeks agoMerge pull request #2892 from antekone/feature/8192-filters-memleak/1
Tim Kientzle [Sat, 7 Mar 2026 18:09:26 +0000 (10:09 -0800)] 
Merge pull request #2892 from antekone/feature/8192-filters-memleak/1

RAR5 reader: fix potential memory leak

7 weeks agoMerge pull request #2893 from antekone/feature/github/1963/init-twice/1
Tim Kientzle [Sat, 7 Mar 2026 18:08:49 +0000 (10:08 -0800)] 
Merge pull request #2893 from antekone/feature/github/1963/init-twice/1

RAR5 reader: fix SIGSEGV when archive_read_support_format_rar5 is called twice

7 weeks agoMerge pull request #2895 from antekone/feature/github-1980/memleak-in-cab/1
Tim Kientzle [Sat, 7 Mar 2026 18:07:49 +0000 (10:07 -0800)] 
Merge pull request #2895 from antekone/feature/github-1980/memleak-in-cab/1

CAB reader: fix memory leak on repeated calls to archive_read_support_format_cab

7 weeks agoCAB reader: fix memory leak on repeated calls to archive_read_support_format_cab 2895/head
Grzegorz Antoniak [Sat, 7 Mar 2026 10:30:06 +0000 (11:30 +0100)] 
CAB reader: fix memory leak on repeated calls to archive_read_support_format_cab

`archive_read_support_format_cab` allocates a fresh context structure on
each call before registering the CAB format with libarchive. On the
second call, however, the registration step reports the format is
already registered, so the function frees the newly allocated context
structure — it is not needed, since the one from the first call is
already in use.

The context structure contains a `ws` field of type `archive_wstring`.
During initialization, `archive_wstring_ensure` is called on that field,
which performs its own heap allocation.

The cleanup path described above frees the context structure without
also releasing the memory owned by the `ws` field, causing a leak.

Fixed by calling `archive_wstring_free` on the `ws` field before freeing
the context structure.

Fixes #1980.

7 weeks agoMerge pull request #2888 from seb128/archive-read-valgrind
Tim Kientzle [Sat, 7 Mar 2026 01:33:15 +0000 (17:33 -0800)] 
Merge pull request #2888 from seb128/archive-read-valgrind

archive_read: optimize string copy, avoid redundant strlen

7 weeks agoRAR5 reader: fix SIGSEGV when archive_read_support_format_rar5 is called twice 2893/head
Grzegorz Antoniak [Fri, 6 Mar 2026 18:52:22 +0000 (19:52 +0100)] 
RAR5 reader: fix SIGSEGV when archive_read_support_format_rar5 is called twice

When the same archive_read object registers rar5 format more than once,
__archive_read_register_format returns ARCHIVE_WARN (duplicate bid).
The error path then called rar5_cleanup(ar), which dereferences
a->format to get the rar5 context — but a->format is NULL until
archive_read_open() is called, causing a SIGSEGV. The newly allocated
rar struct was also leaked.

Fix by introducing rar5_deinit() (the inverse of rar5_init) and using
it in both rar5_cleanup() and the registration error path. On failure,
the locally allocated rar is freed directly without going through
a->format. The function now always returns ARCHIVE_OK, consistent with
all other format handlers.

Fixes #1963.

7 weeks agoRAR5 reader: fix potential memory leak 2892/head
Grzegorz Antoniak [Fri, 6 Mar 2026 18:03:38 +0000 (19:03 +0100)] 
RAR5 reader: fix potential memory leak

If a file declares more than 8192 filters at once, without consuming
them, then the filter allocation function leaks memory.

The backing array used for storing filter pointers can hold up to 8192
pointers. After that it won't accept any new entries. The problem was
that the caller code didn't check if the backing array has accepted the
pointer; it silently assumed the pointer was registered, disposing the
only variable that was holding the pointer to allocated memory.

The fix is to fail the creation of a new filter structure if the backing
array is full. This will result in failure to unpack, but having more
than 8192 filters in one file at the same time seems unlikely.

Fixes issue #2891

7 weeks agoFix double-free in libarchive_linkify_fuzzer 2889/head
OwenSanzas [Thu, 5 Mar 2026 19:03:46 +0000 (19:03 +0000)] 
Fix double-free in libarchive_linkify_fuzzer

The fuzzer fails to update entries[i] after archive_entry_linkify()
modifies the pointer (caching or swapping entries). This causes the
cleanup loop to free entries that were already freed via spare or
the drain loop, resulting in heap-use-after-free.

Fix: add entries[i] = entry after the linkify call to track ownership.

7 weeks agoarchive_read: optimize string copy, avoid redundant strlen 2888/head
Sebastien Bacher [Thu, 5 Mar 2026 12:24:30 +0000 (13:24 +0100)] 
archive_read: optimize string copy, avoid redundant strlen

Calculate the filename length only once during read_file_data
initialization and replace strcpy with memcpy.

As a side effect it also helps silencing valgrind warnings due to strcpy
word-based optimization
https://github.com/libarchive/libarchive/issues/2887

7 weeks agoMerge pull request #2885 from kpatsakis/signature-malloc-null-check
Tim Kientzle [Wed, 4 Mar 2026 04:38:33 +0000 (20:38 -0800)] 
Merge pull request #2885 from kpatsakis/signature-malloc-null-check

Unchecked malloc result in archive_read_support_filter_program_signature()

8 weeks agoIf malloc() returns NULL (e.g., under memory pressure, container memory limits, or... 2885/head
Constantinos Patsakis [Mon, 2 Mar 2026 19:40:53 +0000 (21:40 +0200)] 
If malloc() returns NULL (e.g., under memory pressure, container memory limits, or constrained embedded environments), the subsequent memcpy(NULL, ...) produces a SIGSEGV.

8 weeks agoMerge pull request #2855 from dag-erling/des/mkdir-errno
Tim Kientzle [Mon, 2 Mar 2026 18:17:48 +0000 (10:17 -0800)] 
Merge pull request #2855 from dag-erling/des/mkdir-errno

archive_write_disk_posix: Report correct error

8 weeks agoUnbreak CMake build 2855/head
Dag-Erling Smørgrav [Mon, 2 Mar 2026 17:18:32 +0000 (18:18 +0100)] 
Unbreak CMake build

8 weeks agoMerge pull request #2856 from bradking/pathname-encoding
Tim Kientzle [Mon, 2 Mar 2026 15:20:23 +0000 (07:20 -0800)] 
Merge pull request #2856 from bradking/pathname-encoding

archive_write: Fix crash on failure to convert WCS/UTF-8 pathname to MBS

8 weeks agotest_main: Run tests as unprivileged user
Dag-Erling Smørgrav [Mon, 2 Mar 2026 10:47:12 +0000 (11:47 +0100)] 
test_main: Run tests as unprivileged user

If run as root (as is the case in CI), switch to an unprivileged user
(default: nobody) before running each test, and switch back after.
This makes it possible to write tests that rely on file permissions.

Note that tests that use the UID or GID must now check the EUID / EGID
instead as they will be different while the test is running.  The only
way to avoid that is to run each test case in a child process, which
would hugely increase the complexity of test_run().

8 weeks agotest_main: Add assertChown
Dag-Erling Smørgrav [Mon, 2 Mar 2026 10:42:01 +0000 (11:42 +0100)] 
test_main: Add assertChown

8 weeks agoAdd test case for failing to create directory
Dag-Erling Smørgrav [Fri, 6 Feb 2026 10:14:08 +0000 (11:14 +0100)] 
Add test case for failing to create directory

8 weeks agoarchive_write_disk_posix: Report correct error
Dag-Erling Smørgrav [Fri, 6 Feb 2026 00:54:50 +0000 (01:54 +0100)] 
archive_write_disk_posix: Report correct error

When create_dir() fails to create a directory, it immediately checks to
see if the directory already exists, which can happen if it's been given
something like foo/../foo.  Unfortunately, this clobbers errno, which
means that create_dir() always reports ENOENT, regardless of the actual
error.  Fix this by only performing this extra check if errno is EEXIST,
then reset errno to either EEXIST or ENOTDIR depending on the outcome.

8 weeks agoMerge pull request #2880 from kientzle/kientzle-lha-oversize-header
Tim Kientzle [Sun, 1 Mar 2026 23:27:25 +0000 (15:27 -0800)] 
Merge pull request #2880 from kientzle/kientzle-lha-oversize-header

Reject LHA archives with ridiculously large headers

8 weeks agoRemove unused var 2880/head
Tim Kientzle [Sun, 1 Mar 2026 21:52:57 +0000 (13:52 -0800)] 
Remove unused var

8 weeks agoReject LHA archives with ridiculously large headers
Tim Kientzle [Sun, 1 Mar 2026 21:45:50 +0000 (13:45 -0800)] 
Reject LHA archives with ridiculously large headers

The header is a series of blocks, most of which contain
values of just a few bytes (sizes, times, etc).  The only
exceptions are the filename and directory name attributes,
which will be limited by the MSDOS/Windows maximum file length
limit.  So it seems unlikely that this will ever exceed 64k.
(If we find counter-examples, we can easily extend this limit.)

8 weeks agoMerge pull request #2878 from LoboQ1ng/fix-mtree-fd-leak
Tim Kientzle [Sun, 1 Mar 2026 20:46:39 +0000 (12:46 -0800)] 
Merge pull request #2878 from LoboQ1ng/fix-mtree-fd-leak

Fix file descriptor leak in mtree parser cleanup (CWE-775)

8 weeks agoMerge pull request #2879 from kientzle/kientzle-prune-freebsd-ci
Tim Kientzle [Sun, 1 Mar 2026 20:45:55 +0000 (12:45 -0800)] 
Merge pull request #2879 from kientzle/kientzle-prune-freebsd-ci

Prune FreeBSD CI from 10 variations down to 3

8 weeks agoNon-snap images are RELEASE, not STABLE 2879/head
Tim Kientzle [Sun, 1 Mar 2026 20:31:48 +0000 (12:31 -0800)] 
Non-snap images are RELEASE, not STABLE

8 weeks agoDon't use snap image here
Tim Kientzle [Sun, 1 Mar 2026 20:30:09 +0000 (12:30 -0800)] 
Don't use snap image here

8 weeks agoPrune FreeBSD CI from 10 variations down to 3
Tim Kientzle [Sun, 1 Mar 2026 20:17:05 +0000 (12:17 -0800)] 
Prune FreeBSD CI from 10 variations down to 3

Previously, we tested many combinations of FreeBSD version, build system, and filesystem.
In practice, that's redundant, and we've started seeing these excessive requests get throttled by Cirrus.
Cutting back to just 3 combinations should suffice and reduce the risk of throttling.

8 weeks agomtree: fix file descriptor leak in cleanup 2878/head
LoboQ1ng [Sun, 1 Mar 2026 19:53:47 +0000 (19:53 +0000)] 
mtree: fix file descriptor leak in cleanup

Close any dangling file descriptor in the mtree cleanup function to prevent FD exhaustion (CWE-775) when a read loop is aborted early.

8 weeks agoMerge pull request #2875 from bradking/7z-elf64
Tim Kientzle [Sat, 28 Feb 2026 04:15:39 +0000 (20:15 -0800)] 
Merge pull request #2875 from bradking/7z-elf64

7zip: Fix out-of-bounds access on ELF 64-bit header

8 weeks ago7zip: Fix out-of-bounds access on ELF 64-bit header 2875/head
Brad King [Fri, 27 Feb 2026 19:35:55 +0000 (14:35 -0500)] 
7zip: Fix out-of-bounds access on ELF 64-bit header

The ELF specification's `Elf64_Ehdr` type is 64 bytes [1].
`find_elf_data_sec` accesses the last field, `e_shstrndx`.
Make sure we read enough data to populate it.

[1] https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html

2 months agolibarchive: Correctly handle option failures 2871/head
Tobias Stoeckmann [Sun, 22 Feb 2026 13:42:39 +0000 (14:42 +0100)] 
libarchive: Correctly handle option failures

If an incorrect option value has been passed to a filter, it is possible
that library operations continue without even printing a warning.

This can happen because the special value "ARCHIVE_WARN - 1" is only
checked for filter issues, not format issues. Since this special value
is larger than ARCHIVE_FAILED, such failures are silently discarded.

Fix this by checking for this magic value for formats as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months ago7zip: Fix SEGV in check_7zip_header_in_sfx via ELF offset validation 2864/head
Vijay D'Silva [Thu, 12 Feb 2026 03:51:51 +0000 (03:51 +0000)] 
7zip: Fix SEGV in check_7zip_header_in_sfx via ELF offset validation

The crash reported in this issue is caused by a segmentation fault
that happens when a pointer `p` passed to `check_7zip_header_in_sfx`
is dereferenced. That argument `p` is defined as `p = buff + offset` in
`archive_read_format_7zip_bid` with `offset` determined by a call
to `find_elf_data_sec`.

Within `find_elf_data_sec`, a 64-bit ELF section offset is cast
to `ssize_t`. For a sufficiently large offset, such as an unsigned
64-bit value exceeding `SSIZE_MAX`, the `ssize_t` will be negative,
which leads to `p` to point before the start of the buffer.

This patch eliminates the problem by:
1. Reading the ELF section offset into a `uint64_t`.
2. Validating that the offset does not exceed `SSIZE_MAX`.
3. If the offset is invalid, breaking the loop to retain the safe
   default `SFX_MIN_ADDR`.

These checks ensure that `min_addr` is always within the bounds of the buffer.
This PR includes a regression test `test_malformed3` in
`test_read_format_7zip_malformed.c` using a crafted reproducer file.

CodeMender verified with AddressSanitizer that the crash is resolved and the
test suite passes.

Co-authored-by: CodeMender <codemender-patching@google.com>
Fixes: https://issues.oss-fuzz.com/issues/470963352
2 months agoMerge pull request #2858 from FooIbar/nettle-4.x
Tim Kientzle [Wed, 11 Feb 2026 04:00:27 +0000 (20:00 -0800)] 
Merge pull request #2858 from FooIbar/nettle-4.x

Fix incompatibility with Nettle 4.x

2 months agoMerge pull request #2860 from xTibor/fix-iso-year
Tim Kientzle [Wed, 11 Feb 2026 03:43:31 +0000 (19:43 -0800)] 
Merge pull request #2860 from xTibor/fix-iso-year

bsdunzip: Fix ISO week year and Gregorian year confusion

2 months agoMerge pull request #2859 from zhangjy1014/fix-issue-2744
Tim Kientzle [Mon, 9 Feb 2026 15:20:41 +0000 (07:20 -0800)] 
Merge pull request #2859 from zhangjy1014/fix-issue-2744

Fix NULL pointer dereference in archive_acl_from_text_w()

2 months agobsdunzip: Fix ISO week year and Gregorian year confusion 2860/head
Nagy Tibor [Mon, 9 Feb 2026 05:39:22 +0000 (06:39 +0100)] 
bsdunzip: Fix ISO week year and Gregorian year confusion

2 months agoAdd test for malformed "default" ACL prefix (issue #2744) 2859/head
zhangjy1014 [Mon, 9 Feb 2026 03:20:18 +0000 (11:20 +0800)] 
Add test for malformed "default" ACL prefix (issue #2744)

Verify that archive_entry_acl_from_text() and
archive_entry_acl_from_text_w() return ARCHIVE_WARN instead of
crashing when given a bare "d" or "default" string with no
subsequent tag field.

Without the accompanying fix in archive_acl.c this test triggers
a NULL-pointer dereference (SEGV) in archive_acl_from_text_w().

2 months agoFix NULL pointer dereference in archive_acl_from_text_w()
zhangjy1014 [Sun, 8 Feb 2026 09:18:43 +0000 (17:18 +0800)] 
Fix NULL pointer dereference in archive_acl_from_text_w()

When parsing a short "default" ACL prefix (e.g. L"d") with no
subsequent tag field, field[n] is left as {NULL, NULL} and the
code dereferences it unconditionally in the switch statement,
causing a SEGV.

Add a zero-length check after computing the field length so that
malformed entries are skipped with ARCHIVE_WARN, matching the
documented contract. Also move the st pointer computation after
the guard to avoid dereferencing a NULL start pointer.

Fixes libarchive/libarchive#2744

2 months agoFix incompatibility with Nettle 4.x 2858/head
FooIbar [Fri, 6 Feb 2026 12:52:25 +0000 (20:52 +0800)] 
Fix incompatibility with Nettle 4.x

2 months agoarchive_write: Fix crash on failure to convert WCS/UTF-8 pathname to MBS 2856/head
Brad King [Wed, 4 Feb 2026 21:35:03 +0000 (16:35 -0500)] 
archive_write: Fix crash on failure to convert WCS/UTF-8 pathname to MBS

If an entry pathname is set only by WCS or UTF-8, it may not have any
MBS representation in the archive's hdrcharset.  Do not crash or create
an archive with an empty pathname.  Furthermore, the entry pathname may
not have any MBS representation in the current locale.  Do not report a
`(null)` pathname in the error message.

2 months agoarchive_string_append_from_wcs: Fix silently lossy conversions on Windows
Brad King [Wed, 4 Feb 2026 21:42:26 +0000 (16:42 -0500)] 
archive_string_append_from_wcs: Fix silently lossy conversions on Windows

On Windows, since commit ae54394104 (Implement a string conversion
interface..., 2011-05-09, v3.0.0a~398), `archive_string_append_from_wcs`
no longer returns an error on use of replacement characters in non-C
locales.  Restore the error to avoid silent use of replacement
characters, and for consistency across platforms.

2 months agoarchive_string_conversion_charset_name: Fix calls for current locale
Brad King [Wed, 4 Feb 2026 21:08:05 +0000 (16:08 -0500)] 
archive_string_conversion_charset_name: Fix calls for current locale

Some code paths may call `archive_string_conversion_charset_name(sconv)`
with `sconv == NULL` when converting to/from the current locale.

2 months agoarchive_mstring_get_mbs_l: Restore error on failure to convert from WCS/UTF-8
Brad King [Wed, 4 Feb 2026 21:22:39 +0000 (16:22 -0500)] 
archive_mstring_get_mbs_l: Restore error on failure to convert from WCS/UTF-8

Prior to commit c30f279475 (Complete support for UTF8 encoding
conversion, 2020-05-31, v3.5.0~32^2), `archive_mstring_get_mbs_l` returned
an error on failure to convert WCS to MBS.  Restore the error so callers
can distinguish conversion failure from having no string in any form.

On Windows, `archive_mstring_get_mbs_l` from WCS with `sconv != NULL`
internally calls `archive_string_append_from_wcs_in_codepage` more than
once, with both `sconv != NULL` and `sconv == NULL`.  Due to another bug
in the `sconv == NULL` case, we cannot enable all test combinations yet.

2 months agoarchive_string_append_from_wcs: add test case for conversion failure
Brad King [Thu, 5 Feb 2026 14:05:57 +0000 (09:05 -0500)] 
archive_string_append_from_wcs: add test case for conversion failure

3 months agoMerge pull request #2838 from DHowett/revert-2826-waitpid
Martin Matuška [Wed, 7 Jan 2026 22:38:30 +0000 (23:38 +0100)] 
Merge pull request #2838 from DHowett/revert-2826-waitpid

Revert "Wait for the process instead of busy wait loop"

3 months agoRevert "Wait for the process instead of busy wait loop" 2838/head
Dustin L. Howett [Wed, 7 Jan 2026 21:42:41 +0000 (13:42 -0800)] 
Revert "Wait for the process instead of busy wait loop"

3 months agoMerge pull request #2781 from AZero13/ints
Martin Matuška [Mon, 5 Jan 2026 09:35:59 +0000 (10:35 +0100)] 
Merge pull request #2781 from AZero13/ints

Remove unneeded int cast

3 months agoMerge pull request #2826 from AZero13/waitpid
Martin Matuška [Mon, 5 Jan 2026 09:33:33 +0000 (10:33 +0100)] 
Merge pull request #2826 from AZero13/waitpid

Wait for the process instead of busy wait loop

3 months agoMerge pull request #2836 from ngie-eign/add-freebsd-15-cirrus-ci
Martin Matuška [Mon, 5 Jan 2026 09:32:49 +0000 (10:32 +0100)] 
Merge pull request #2836 from ngie-eign/add-freebsd-15-cirrus-ci

Expand the test matrix to include 15.x images/ZFS

3 months agoExpand the test matrix to include 15.x images/ZFS 2836/head
Enji Cooper [Mon, 5 Jan 2026 01:55:34 +0000 (17:55 -0800)] 
Expand the test matrix to include 15.x images/ZFS

This change adds support for the following test scenarios:

- 15.0-RELEASE - ZFS
- 15.0-STABLE - UFS
- 15.0-STABLE - ZFS

This additional testing aims to catch issues with 15.x, as well as
ensure libarchive use doesn't regress when run on ZFS-based hosts.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
3 months agoMerge pull request #2835 from jmcarp/build-illumos
Tim Kientzle [Wed, 31 Dec 2025 23:31:55 +0000 (15:31 -0800)] 
Merge pull request #2835 from jmcarp/build-illumos

Skip unsupported linker options on illumos.

3 months agoSkip unsupported linker options on illumos. 2835/head
Josh Carp [Wed, 31 Dec 2025 22:37:01 +0000 (22:37 +0000)] 
Skip unsupported linker options on illumos.

Building on illumos currently fails with:

```
ld: fatal: unrecognized option '--gc-sections'
```

This happens because `--gc-sections` isn't supported on illumos `ld`.
This patch updates CMakeLists.txt to skip unsupported linker options on
illumos. The flags used on other operating systems are optimizations
that don't affect correctness, so this change is safe.

4 months agoMerge pull request #2825 from AZero13/patch-2
Tim Kientzle [Sat, 27 Dec 2025 18:52:17 +0000 (10:52 -0800)] 
Merge pull request #2825 from AZero13/patch-2

Error check ret before calling copy_seek_stat

4 months agoMerge pull request #2824 from AZero13/qosflags
Tim Kientzle [Sat, 27 Dec 2025 18:48:03 +0000 (10:48 -0800)] 
Merge pull request #2824 from AZero13/qosflags

Remove bitmask typo in dwSecurityQosFlags

4 months agoMerge pull request #2827 from AZero13/free
Tim Kientzle [Sat, 27 Dec 2025 18:31:27 +0000 (10:31 -0800)] 
Merge pull request #2827 from AZero13/free

Simplify file free

4 months agoMerge pull request #2829 from AZero13/leak-shar
Tim Kientzle [Sat, 27 Dec 2025 18:30:22 +0000 (10:30 -0800)] 
Merge pull request #2829 from AZero13/leak-shar

archive_write_shar_header: free shar->last_dir before replacement

4 months agoMerge pull request #2830 from AZero13/return
Tim Kientzle [Sat, 27 Dec 2025 18:28:27 +0000 (10:28 -0800)] 
Merge pull request #2830 from AZero13/return

return early if archive_write_set_format_shar fails

4 months agoMerge pull request #2831 from AZero13/check-copy-length
Tim Kientzle [Sat, 27 Dec 2025 18:27:12 +0000 (10:27 -0800)] 
Merge pull request #2831 from AZero13/check-copy-length

Use copy_length as upper-bound, not strlen(p)

4 months agoMerge pull request #2834 from AZero13/patch-5
Tim Kientzle [Sat, 27 Dec 2025 18:21:44 +0000 (10:21 -0800)] 
Merge pull request #2834 from AZero13/patch-5

Use #warning, not #warn

4 months agoarchive_write_shar_header: free shar->last_dir before replacement 2829/head
AZero13 [Fri, 26 Dec 2025 20:02:24 +0000 (15:02 -0500)] 
archive_write_shar_header: free shar->last_dir before replacement

4 months agoUse #warning, not #warn 2834/head
AZero13 [Fri, 26 Dec 2025 20:28:12 +0000 (15:28 -0500)] 
Use #warning, not #warn

#warn is a GNU extension

4 months agoUse copy_length as upper-bound, not strlen(p) 2831/head
AZero13 [Fri, 26 Dec 2025 20:09:10 +0000 (15:09 -0500)] 
Use copy_length as upper-bound, not strlen(p)

4 months agoreturn early if archive_write_set_format_shar fails 2830/head
AZero13 [Fri, 26 Dec 2025 20:05:46 +0000 (15:05 -0500)] 
return early if archive_write_set_format_shar fails

4 months agoSimplify file free 2827/head
AZero13 [Fri, 26 Dec 2025 19:42:23 +0000 (14:42 -0500)] 
Simplify file free

free is fine if NULL

4 months agoWait for the process instead of busy wait loop 2826/head
AZero13 [Fri, 26 Dec 2025 18:05:57 +0000 (13:05 -0500)] 
Wait for the process instead of busy wait loop

4 months agoError check ret before calling copy_seek_stat 2825/head
AZero13 [Fri, 26 Dec 2025 18:29:14 +0000 (13:29 -0500)] 
Error check ret before calling copy_seek_stat

4 months agoRemove bitmask typo in dwSecurityQosFlags 2824/head
AZero13 [Fri, 26 Dec 2025 18:19:56 +0000 (13:19 -0500)] 
Remove bitmask typo in dwSecurityQosFlags

We seemed to have been isolating the wrong flags.

4 months agoMerge pull request #2813 from AZero13/memcpy
Martin Matuška [Fri, 26 Dec 2025 09:22:13 +0000 (10:22 +0100)] 
Merge pull request #2813 from AZero13/memcpy

We copy from p, not p + module_len

4 months agoMerge pull request #2796 from vcoxvco/fix_unninit
Martin Matuška [Thu, 25 Dec 2025 09:16:46 +0000 (10:16 +0100)] 
Merge pull request #2796 from vcoxvco/fix_unninit

libarchive/archive_util.c: Uninitialized variable

4 months agoMerge pull request #2816 from AZero13/strdup
Martin Matuška [Thu, 25 Dec 2025 09:14:23 +0000 (10:14 +0100)] 
Merge pull request #2816 from AZero13/strdup

Error check strdup for path name

4 months agoMerge pull request #2814 from AZero13/gname
Martin Matuška [Thu, 25 Dec 2025 09:04:44 +0000 (10:04 +0100)] 
Merge pull request #2814 from AZero13/gname

uname_override checks gname_override when it should check uname_override

4 months agoMerge pull request #2789 from libarchive/dependabot/github_actions/all-actions-50b857948b
Martin Matuška [Thu, 25 Dec 2025 09:03:34 +0000 (10:03 +0100)] 
Merge pull request #2789 from libarchive/dependabot/github_actions/all-actions-50b857948b

CI: Bump the all-actions group across 1 directory with 3 updates

4 months agoMerge pull request #2815 from AZero13/=
Martin Matuška [Thu, 25 Dec 2025 09:00:35 +0000 (10:00 +0100)] 
Merge pull request #2815 from AZero13/=

Use >=, not =>

4 months agoCI: Bump the all-actions group across 1 directory with 3 updates 2789/head
dependabot[bot] [Thu, 25 Dec 2025 08:53:17 +0000 (08:53 +0000)] 
CI: Bump the all-actions group across 1 directory with 3 updates

Bumps the all-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [github/codeql-action](https://github.com/github/codeql-action).

Updates `actions/checkout` from 5.0.0 to 5.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/08c6903cd8c0fde910a37f88322edcfb5dd907a8...93cb6efe18208431cddfb8368fd83d5badbf9bfd)

Updates `actions/upload-artifact` from 4.6.2 to 5.0.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/ea165f8d65b6e75b540449e92b4886f43607fa02...330a01c490aca151604b8cf639adc76d48f6c5d4)

Updates `github/codeql-action` from 3.30.6 to 4.31.3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/64d10c13136e1c5bce3e5fbde8d4906eeaafc885...014f16e7ab1402f30e7c3329d33797e7948572db)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: actions/upload-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: github/codeql-action
  dependency-version: 4.31.3
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
4 months agoMerge pull request #2819 from GabrielBarrantes/work/typos
Martin Matuška [Thu, 25 Dec 2025 08:48:17 +0000 (09:48 +0100)] 
Merge pull request #2819 from GabrielBarrantes/work/typos

Improve wording

4 months agoMerge pull request #2820 from skypher/oss-fuzz-expansion
Martin Matuška [Thu, 25 Dec 2025 08:47:17 +0000 (09:47 +0100)] 
Merge pull request #2820 from skypher/oss-fuzz-expansion

Expand OSS-Fuzz integration: 1 → 25 fuzz targets

4 months agoRefactor all fuzzers to use shared fuzz_helpers.h 2820/head
Leslie P. Polzer [Mon, 22 Dec 2025 04:53:06 +0000 (04:53 +0000)] 
Refactor all fuzzers to use shared fuzz_helpers.h

Complete the refactoring of all 25 fuzzers:
- Remove duplicate Buffer struct definitions from 15 format fuzzers
- Remove duplicate DataConsumer class from 7 API fuzzers
- Update consume_bytes() calls to match new signature
- All fuzzers now use shared helpers from fuzz_helpers.h

This eliminates ~1000 lines of duplicated code.

4 months agoRefactor fuzzers: add shared header, remove system() call
Leslie P. Polzer [Mon, 22 Dec 2025 04:26:57 +0000 (04:26 +0000)] 
Refactor fuzzers: add shared header, remove system() call

- Add fuzz_helpers.h with shared Buffer, reader_callback, DataConsumer
- Replace system("rm -rf") with nftw-based remove_directory_tree()
- Refactor entry, tar, write_disk fuzzers to use shared helpers
- Reduces code duplication and improves maintainability

4 months agoExpand OSS-Fuzz integration: 1 → 25 fuzz targets
Leslie P. Polzer [Mon, 22 Dec 2025 04:08:26 +0000 (04:08 +0000)] 
Expand OSS-Fuzz integration: 1 → 25 fuzz targets

Add comprehensive fuzzing coverage for libarchive:

Format-specific fuzzers (13):
- tar, zip, 7zip, rar, rar5, xar, cab, lha, iso9660, cpio, warc, mtree, ar

Security-critical fuzzers (4):
- encryption: encrypted archive handling
- write_disk: extraction path traversal
- read_disk: filesystem traversal, symlinks
- entry: ACL functions (previously 0% coverage)

API fuzzers (7):
- write: archive creation
- linkify: hardlink detection (complexity 775, was 0%)
- match: inclusion/exclusion patterns
- string: encoding conversions (UTF-8, wide chars)
- seek: seekable archive operations
- roundtrip: write-then-read consistency
- filter: compression/decompression

Supporting files:
- 14 dictionaries with format-specific magic bytes
- 9 options files for complex fuzzers
- Updated build script with seed corpora generation

Targets previously uncovered functions:
- archive_entry_linkify (complexity 775)
- ACL functions (complexity 705-713)
- xar_read_header (was 10.11% coverage)

Expected coverage improvement: 74% → 85-95%

4 months agoImprove wording 2819/head
Gabriel Barrantes [Sun, 21 Dec 2025 23:30:42 +0000 (17:30 -0600)] 
Improve wording