]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
11 days agoMerge pull request #2947 from fdegros/lzop_support master
Tim Kientzle [Sun, 29 Mar 2026 23:34:20 +0000 (16:34 -0700)] 
Merge pull request #2947 from fdegros/lzop_support

LZOP and GRZIP support

13 days agoAdd tests 2947/head
François Degros [Mon, 24 Feb 2025 23:19:12 +0000 (10:19 +1100)] 
Add tests

test_read_append_lzop_filter
test_read_append_grzip_filter

Bug: https://github.com/libarchive/libarchive/issues/2513
Test: ./libarchive_test test_read_append_lzop_filter test_read_append_grzip_filter

13 days agoFix archive_read_append_filter() for lzop and grzip
Tim Kientzle [Sun, 27 Jul 2025 15:50:03 +0000 (08:50 -0700)] 
Fix archive_read_append_filter() for lzop and grzip

These two filters failed to correctly set a name when
being registered, which prevented them from working
correctly with archive_read_append_filter()

Thanks to @fdegros for the test case demonstrating the lrzip failure

2 weeks agoMerge pull request #2943 from bgilbert/test
Tim Kientzle [Sun, 22 Mar 2026 17:34:40 +0000 (10:34 -0700)] 
Merge pull request #2943 from bgilbert/test

Add v7 tar filename encoding test to Autotools

2 weeks agoAdd v7 tar filename encoding test to Autotools 2943/head
Benjamin Gilbert [Sun, 22 Mar 2026 03:48:19 +0000 (20:48 -0700)] 
Add v7 tar filename encoding test to Autotools

It wasn't being included in the dist tarball.

Fixes: d4cf95cdac ("archive_write: Fix crash on failure to convert WCS/UTF-8 pathname to MBS")
2 weeks agoMerge pull request #2919 from LoboQ1ng/fix-cab-lzx-oob
Tim Kientzle [Sat, 21 Mar 2026 02:11:15 +0000 (19:11 -0700)] 
Merge pull request #2919 from LoboQ1ng/fix-cab-lzx-oob

Fix Heap OOB Write in CAB LZX decoder

2 weeks agobuild: add test files to Makefile.am for autotools compatibility 2919/head
LoboQ1ng [Sat, 21 Mar 2026 00:27:12 +0000 (00:27 +0000)] 
build: add test files to Makefile.am for autotools compatibility

2 weeks agotest: resolve SonarQube code smell by removing redundant conditional
LoboQ1ng [Fri, 20 Mar 2026 21:57:18 +0000 (21:57 +0000)] 
test: resolve SonarQube code smell by removing redundant conditional

2 weeks agoMerge pull request #2939 from stoeckmann/cpio_mem_leak
Tim Kientzle [Fri, 20 Mar 2026 15:44:15 +0000 (08:44 -0700)] 
Merge pull request #2939 from stoeckmann/cpio_mem_leak

cpio: Fix `-R` memory leak

2 weeks agoMerge pull request #2940 from wrp/wrp/doc
Tim Kientzle [Fri, 20 Mar 2026 15:43:08 +0000 (08:43 -0700)] 
Merge pull request #2940 from wrp/wrp/doc

Provide more details on autotool meta-files

2 weeks agoProvide more details on autotool meta-files 2940/head
William Pursell [Fri, 20 Mar 2026 15:03:59 +0000 (09:03 -0600)] 
Provide more details on autotool meta-files

Given the amount of confusion surrounding the autotools, it is
better to have accurate descriptions of these files in the
README.

2 weeks agocpio: Fix -R memory leak 2939/head
Tobias Stoeckmann [Fri, 20 Mar 2026 12:40:19 +0000 (13:40 +0100)] 
cpio: Fix -R memory leak

If the -R command line argument is supplied with user/group names
multiple times, memory leaks occur.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #2921 from stoeckmann/err_style_regression
Tim Kientzle [Wed, 18 Mar 2026 12:58:45 +0000 (05:58 -0700)] 
Merge pull request #2921 from stoeckmann/err_style_regression

Fix Windows test regression

3 weeks agoFix Windows test regression 2921/head
Tobias Stoeckmann [Wed, 18 Mar 2026 08:03:00 +0000 (09:03 +0100)] 
Fix Windows test regression

By only removing periods from error messages in Windows specific code,
but not adjusting its POSIX counterpart, the test fails on Windows but
not on POSIX systems.

Fix this by removing the period in test and in POSIX error messages.

Fixes: 3e0819b59e ("libarchive: Remove period from error messages")
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #2912 from stoeckmann/pax_ugid
Tim Kientzle [Wed, 18 Mar 2026 03:11:29 +0000 (20:11 -0700)] 
Merge pull request #2912 from stoeckmann/pax_ugid

pax: Remove uid/gid cast in value range check

3 weeks agoMerge pull request #2913 from stoeckmann/cpio_buff
Tim Kientzle [Wed, 18 Mar 2026 03:09:54 +0000 (20:09 -0700)] 
Merge pull request #2913 from stoeckmann/cpio_buff

cpio: Reduce visibility of variable buff

3 weeks agoMerge pull request #2915 from stoeckmann/err_style
Tim Kientzle [Wed, 18 Mar 2026 03:07:55 +0000 (20:07 -0700)] 
Merge pull request #2915 from stoeckmann/err_style

libarchive: Improve error message style

3 weeks agoFix Heap OOB Write in CAB LZX decoder
LoboQ1ng [Wed, 18 Mar 2026 00:24:40 +0000 (00:24 +0000)] 
Fix Heap OOB Write in CAB LZX decoder

3 weeks agolibarchive: Fix error message style 2915/head
Tobias Stoeckmann [Tue, 17 Mar 2026 09:47:52 +0000 (10:47 +0100)] 
libarchive: Fix error message style

Remove space in front of colon to match rest of messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolibarchive: Remove "Failed : " error prefixes
Tobias Stoeckmann [Tue, 17 Mar 2026 09:46:25 +0000 (10:46 +0100)] 
libarchive: Remove "Failed : " error prefixes

Calling archive_set_error with a message and errno already indicates
that a failure occurred. Only a minority of functions did that: Unify
with the rest.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolibarchive: Remove period from error messages
Tobias Stoeckmann [Tue, 17 Mar 2026 09:41:25 +0000 (10:41 +0100)] 
libarchive: Remove period from error messages

The error messages are mostly written without a period. This makes
sense, because they can be accompanied with a strerror(errno) call,
giving more information: most likely a colon is appended.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocpio: Reduce visibility of variable buff 2913/head
Tobias Stoeckmann [Tue, 17 Mar 2026 09:08:42 +0000 (10:08 +0100)] 
cpio: Reduce visibility of variable buff

The buff variable is only used in entry_to_archive. Moving it into the
specific code block where it is actually used reduces its visibility and
thus makes it easier to read the code:

Since Windows indeed uses unsigned for read, this makes it much easier
to verify that buff never grows and cannot be too large.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agopax: Remove uid/gid cast in value range check 2912/head
Tobias Stoeckmann [Tue, 17 Mar 2026 08:35:55 +0000 (09:35 +0100)] 
pax: Remove uid/gid cast in value range check

The API allows to set int64_t uid/gid values. When writing pax archives,
such large values are properly set in the USTAR header of actual data in
base256, i.e. everything works.

The pax header entries might be missing though because the check
truncates these values to unsigned int. Larger values could be truncated
in a way that they seem smaller than (1 << 18).

The check in line 1427 which sets the uid/gid values into the PAX header
block is correct, truncating the actual value to max. octal
representation.

This is a purely defensive change to support parsers which actually
allow such large uid/gid values but do not understand base256 encoding.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #2911 from stoeckmann/libarchive_opt_vals
Tim Kientzle [Mon, 16 Mar 2026 21:01:33 +0000 (14:01 -0700)] 
Merge pull request #2911 from stoeckmann/libarchive_opt_vals

libarchive: Check number ranges of supplied option values

3 weeks agolibarchive/{b64,uu}: Improve atol8 checks 2911/head
Tobias Stoeckmann [Mon, 16 Mar 2026 15:00:30 +0000 (16:00 +0100)] 
libarchive/{b64,uu}: Improve atol8 checks

Make sure that supplied values cannot overflow int64_t, which would be
an undefined behavior. Also do not accept empty strings as numbers.

Last but not least, check values before casting them to target data
types to avoid truncations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolibarchive: Check strto(u)l results before casts
Tobias Stoeckmann [Mon, 16 Mar 2026 14:59:12 +0000 (15:59 +0100)] 
libarchive: Check strto(u)l results before casts

Make sure that supplied option values fit into data types. If not,
return an error instead of silently truncating values.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolibarchive/7zip: Properly check strto* errno value
Tobias Stoeckmann [Mon, 16 Mar 2026 14:57:17 +0000 (15:57 +0100)] 
libarchive/7zip: Properly check strto* errno value

Set errno to 0 before calling strtoimax/strtol and check its value
afterwards.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agolibarchive/gzip: Check strdup return value
Tobias Stoeckmann [Mon, 16 Mar 2026 14:54:16 +0000 (15:54 +0100)] 
libarchive/gzip: Check strdup return value

Handle strdup error instead of silently ignoring the option.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #2910 from stoeckmann/cpio_num
Tim Kientzle [Mon, 16 Mar 2026 13:56:31 +0000 (06:56 -0700)] 
Merge pull request #2910 from stoeckmann/cpio_num

cpio: Check number arguments before casts

3 weeks agoMerge pull request #2909 from stoeckmann/lafe_error
Tim Kientzle [Mon, 16 Mar 2026 13:47:14 +0000 (06:47 -0700)] 
Merge pull request #2909 from stoeckmann/lafe_error

tools: Remove `Error : ` prefix in lafe_errc calls

3 weeks agoMerge pull request #2908 from stoeckmann/cpio_mode
Tim Kientzle [Mon, 16 Mar 2026 13:46:38 +0000 (06:46 -0700)] 
Merge pull request #2908 from stoeckmann/cpio_mode

cpio: Improve mode option handling

3 weeks agocpio: Set lafe_warnc code to 0 2910/head
Tobias Stoeckmann [Mon, 16 Mar 2026 13:34:32 +0000 (14:34 +0100)] 
cpio: Set lafe_warnc code to 0

Otherwise an unknown error is printed, which does not help the user
(especially since a custom message is printed in this case already).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #2872 from stoeckmann/filter_options_failed
Tim Kientzle [Mon, 16 Mar 2026 13:30:07 +0000 (06:30 -0700)] 
Merge pull request #2872 from stoeckmann/filter_options_failed

filter options: Use ARCHIVE_FAILED on errors

3 weeks agoMerge pull request #2899 from stoeckmann/cpio_rename
Tim Kientzle [Mon, 16 Mar 2026 13:28:55 +0000 (06:28 -0700)] 
Merge pull request #2899 from stoeckmann/cpio_rename

cpio: Allow long paths with -r option

3 weeks agocpio: Check number arguments before casts
Tobias Stoeckmann [Mon, 16 Mar 2026 13:10:50 +0000 (14:10 +0100)] 
cpio: Check number arguments before casts

Make sure that supplied arguments actually fit into target data types.
Print an error if numbers are too large instead of silently truncating
them.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agotools: Remove 'Error : ' prefix in lafe_errc calls 2909/head
Tobias Stoeckmann [Mon, 16 Mar 2026 13:01:56 +0000 (14:01 +0100)] 
tools: Remove 'Error : ' prefix in lafe_errc calls

Only a minority of calls to lafe_errc state explicitly that an error
occurred. Remove these few cases for a more unified argument handling.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocpio: Clarify that onyl one mode is acceptable 2908/head
Tobias Stoeckmann [Mon, 16 Mar 2026 12:50:42 +0000 (13:50 +0100)] 
cpio: Clarify that onyl one mode is acceptable

Do not print that at least one mode has to be supplied. Exactly one mode
has to be supplied instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocpio: Improve mode argument checks
Tobias Stoeckmann [Mon, 16 Mar 2026 09:16:19 +0000 (10:16 +0100)] 
cpio: Improve mode argument checks

Complain only if contradicting mode options are supplied. Passing the
same argument multiple times should not lead to errors.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agofilter options: Use ARCHIVE_FAILED on errors 2872/head
Tobias Stoeckmann [Sun, 22 Feb 2026 14:49:27 +0000 (15:49 +0100)] 
filter options: Use ARCHIVE_FAILED on errors

If a filter option is recognized but its value is invalid, return
ARCHIVE_FAILED instead of ARCHIVE_WARN. The latter is used for unknown
options, e.g. at the end of the option setter functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocpio: Use getline in cpio_rename 2899/head
Tobias Stoeckmann [Mon, 9 Mar 2026 20:40:09 +0000 (21:40 +0100)] 
cpio: Use getline in cpio_rename

The buffer has a fixed 1024 limit, which can be smaller than the maximum
allowed path length. Increasing the limit to 4096 would partially help,
but since leading spaces are stripped, input lines could be valid and
longer.

Use getline instead.

3 weeks agocpio: Refactor cpio_rename
Tobias Stoeckmann [Mon, 9 Mar 2026 20:35:09 +0000 (21:35 +0100)] 
cpio: Refactor cpio_rename

Let cpio_rename work with the entry directly. In this initial step, it
moves buff into the stack.

The comment suggests that this was done in the past already.

3 weeks agoMove la_getline into libarchive_fe
Tobias Stoeckmann [Mon, 9 Mar 2026 20:28:00 +0000 (21:28 +0100)] 
Move la_getline into libarchive_fe

This allows easier reuse of the getline implementation in other tools
like cpio (in upcoming commit).

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

3 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

3 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

3 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()

3 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

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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

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

4 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

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

4 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

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

5 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

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

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

5 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

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

5 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

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

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

5 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

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

5 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

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

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

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

5 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

5 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

5 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

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

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

5 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

5 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

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

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

8 weeks 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()

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

8 weeks 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().

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