]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
111 min agoMerge pull request #2957 from kientzle/kientzle-linkresolver master
Tim Kientzle [Tue, 14 Apr 2026 03:14:58 +0000 (20:14 -0700)] 
Merge pull request #2957 from kientzle/kientzle-linkresolver

Fix a double-free in the link resolver

2 hours agoRemove unused variable 2957/head
Tim Kientzle [Tue, 14 Apr 2026 03:00:24 +0000 (20:00 -0700)] 
Remove unused variable

2 hours agoMinor code improvements
Tim Kientzle [Tue, 14 Apr 2026 02:58:12 +0000 (19:58 -0700)] 
Minor code improvements

2 hours agoFix a double-free in the link resolver
Tim Kientzle [Tue, 14 Apr 2026 02:38:07 +0000 (19:38 -0700)] 
Fix a double-free in the link resolver

The link resolver is a helper utility that tracks linked
entries so they can be correctly restored.  Clients add link information
to the link resolver and incrementally query it to correctly
link entries as they are restored to disk.  The link resolver
incrementally releases entries as they are consumed in order
to minimize memory usage.

The `archive_entry_linkresolver_free()` method cleans up
by repeatedly querying the cache and freeing each entry.
But this conflicted with the incremental clean up,
leading to double-frees of leftover items.

The easy fix here is to have `archive_entry_linkresolver_free()`
just repeatedly query the list without trying to free, relying
on the incremental clean up mechanism.

Credit: tianshuo han reported the issue and suggested the fix.

29 hours agoMerge pull request #2952 from solbjorn/ppmd-symbols
Tim Kientzle [Sun, 12 Apr 2026 23:12:07 +0000 (16:12 -0700)] 
Merge pull request #2952 from solbjorn/ppmd-symbols

libarchive/ppmd8: mark the remaining functions static

30 hours agoMerge pull request #2898 from ElhananHaenel/fix/rar3-lzss-window-realloc
Tim Kientzle [Sun, 12 Apr 2026 22:16:57 +0000 (15:16 -0700)] 
Merge pull request #2898 from ElhananHaenel/fix/rar3-lzss-window-realloc

rar: fix LZSS window size mismatch after PPMd block

30 hours agoMerge pull request #2934 from ElhananHaenel/fix/zisofs-validate-log2bs
Tim Kientzle [Sun, 12 Apr 2026 22:13:18 +0000 (15:13 -0700)] 
Merge pull request #2934 from ElhananHaenel/fix/zisofs-validate-log2bs

FIX - iso9660: validate pz_log2_bs, add test for 32-bit heap overflow

31 hours agoMerge pull request #2924 from stoeckmann/pathmatch_pm
Tim Kientzle [Sun, 12 Apr 2026 22:03:02 +0000 (15:03 -0700)] 
Merge pull request #2924 from stoeckmann/pathmatch_pm

pathmatch: Anchors within pattern not special

31 hours agoMerge pull request #2922 from stoeckmann/err_style_followup
Tim Kientzle [Sun, 12 Apr 2026 22:02:13 +0000 (15:02 -0700)] 
Merge pull request #2922 from stoeckmann/err_style_followup

Improve style of more error messages

31 hours agoMerge branch 'master' into fix/zisofs-validate-log2bs 2934/head
Tim Kientzle [Sun, 12 Apr 2026 21:57:23 +0000 (14:57 -0700)] 
Merge branch 'master' into fix/zisofs-validate-log2bs

31 hours agoMerge pull request #2897 from ElhananHaenel/fix/iso_zisofs_undefined_behavior
Tim Kientzle [Sun, 12 Apr 2026 21:51:56 +0000 (14:51 -0700)] 
Merge pull request #2897 from ElhananHaenel/fix/iso_zisofs_undefined_behavior

iso9660: validate pz_log2_bs in parse_rockridge_ZF1()

4 days agoAdd regression test for zisofs 32-bit heap overflow
elhananhaenel [Thu, 19 Mar 2026 14:43:29 +0000 (16:43 +0200)] 
Add regression test for zisofs 32-bit heap overflow

A crafted ISO with pz_log2_bs=2 and pz_uncompressed_size=0xFFFFFFF9
causes an integer overflow in the block pointer allocation in
zisofs_read_data(). On 32-bit, (ceil+1)*4 wraps size_t to 0, malloc(0)
returns a tiny buffer, and the code writes ~4GB past it.

The pz_log2_bs validation fix prevents this. Add a regression test with
a crafted 48KB ISO that triggers the overflow on unfixed 32-bit builds.

5 days agolibarchive/ppmd8: mark the remaining functions static 2952/head
Alexander Lobakin [Tue, 7 Apr 2026 21:10:47 +0000 (23:10 +0200)] 
libarchive/ppmd8: mark the remaining functions static

Those 9 are not used anywhere outside the file (the actual
functionality is exported as a callback structure).
Make them static for a bit better compiler optimization
opportunities and, more important, to avoid symbol conflict
when static linking libarchive and any library which uses
the original Ppmd*.c from the LZMA SDK (like minizip-ng).

Also remove a couple declarations and macros not used
anywhere at all while we're here.

Signed-off-by: Alexander Lobakin <alobakin@mailbox.org>
2 weeks agoMerge pull request #2947 from fdegros/lzop_support
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

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

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

3 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

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

3 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

3 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

3 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

3 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

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

3 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 agopathmatch: Anchors within pattern not special 2924/head
Tobias Stoeckmann [Wed, 18 Mar 2026 10:17:02 +0000 (11:17 +0100)] 
pathmatch: Anchors within pattern not special

The anchor characters ^ and $ have only special meanings if they are
located at the beginning (^) or at the end ($) of the pattern. And even
then they are supposed to be only special if flags are set.

If they are located within the pattern itself, they are regular
characters regardless of flags.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agozip: Unify error code formatting in error messages 2922/head
Tobias Stoeckmann [Wed, 18 Mar 2026 08:20:01 +0000 (09:20 +0100)] 
zip: Unify error code formatting in error messages

This unifies the way error codes are shown in error messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agorar5: Remove "Error: " prefix from error message
Tobias Stoeckmann [Wed, 18 Mar 2026 08:19:15 +0000 (09:19 +0100)] 
rar5: Remove "Error: " prefix from error message

Unifies style with other error messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoFix whitespace style in error messages
Tobias Stoeckmann [Wed, 18 Mar 2026 08:15:53 +0000 (09:15 +0100)] 
Fix whitespace style in error messages

- Keep a whitespace between text and brackets
- No whitespace between text and colon
- No newline at end of error message

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Fix typo in error message
Tobias Stoeckmann [Wed, 18 Mar 2026 08:14:25 +0000 (09:14 +0100)] 
7zip: Fix typo in error message

Failed should be written without capital letter here.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoRemove periods from error messages
Tobias Stoeckmann [Wed, 18 Mar 2026 08:12:51 +0000 (09:12 +0100)] 
Remove periods from error messages

Some error messages previously slipped through. Remove periods from
these messages as well.

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

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

4 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

4 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

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

4 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

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

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

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

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

4 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

4 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

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

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

5 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

5 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

5 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

5 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

5 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

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

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

5 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

5 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

5 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

5 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

5 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

5 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

5 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

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

5 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

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

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

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

6 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

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

6 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

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

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

6 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

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

6 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