]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
2 hours agoMerge pull request #3148 from XananasX7/ci/pin-actions master
Dustin L. Howett [Mon, 15 Jun 2026 20:25:35 +0000 (15:25 -0500)] 
Merge pull request #3148 from XananasX7/ci/pin-actions

ci: pin acj/freebsd-firecracker-action to full commit SHA

2 hours agoMerge pull request #3149 from DHowett/fix-mingw-tests
Dustin L. Howett [Mon, 15 Jun 2026 20:24:06 +0000 (15:24 -0500)] 
Merge pull request #3149 from DHowett/fix-mingw-tests

3 hours agotar: use filesystem-neutral replacement characters in the -s test 3149/head
Dustin L. Howett [Sun, 14 Jun 2026 20:01:29 +0000 (15:01 -0500)] 
tar: use filesystem-neutral replacement characters in the -s test

3 hours agotest: promote the win32-repairing systemf wrapper to all systemf calls
Dustin L. Howett [Sun, 14 Jun 2026 20:01:00 +0000 (15:01 -0500)] 
test: promote the win32-repairing systemf wrapper to all systemf calls

28 hours agoci: pin acj/freebsd-firecracker-action to full commit SHA 3148/head
XananasX7 [Sun, 14 Jun 2026 18:38:24 +0000 (18:38 +0000)] 
ci: pin acj/freebsd-firecracker-action to full commit SHA

  acj/freebsd-firecracker-action: @v0.9.1 -> @bab3e77871573c7943b80816f1641b6c1ce36896

32 hours agoMerge pull request #3143 from stoeckmann/7zip_size_int64
Dustin L. Howett [Sun, 14 Jun 2026 15:01:50 +0000 (10:01 -0500)] 
Merge pull request #3143 from stoeckmann/7zip_size_int64

7zip: Avoid unnecessary int64_t size_t casts

32 hours agoMerge pull request #3146 from stoeckmann/size_t_off
Dustin L. Howett [Sun, 14 Jun 2026 14:59:01 +0000 (09:59 -0500)] 
Merge pull request #3146 from stoeckmann/size_t_off

read_disk: Check if off_t can overflow size_t

38 hours agoread_disk: Check if off_t can overflow size_t 3146/head
Tobias Stoeckmann [Sun, 14 Jun 2026 09:14:03 +0000 (11:14 +0200)] 
read_disk: Check if off_t can overflow size_t

Make sure that the content of the link can fit into a size_t. This
should be always true, but be cautious with 32 bit systems and very
weird filesystems (possibly through fuse).

I took SSIZE_MAX as upper limit due to signedness and eventual readlink
calls which would fail with larger values anyway.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 days ago7zip: Avoid unnecessary int64_t size_t casts 3143/head
Tobias Stoeckmann [Sat, 13 Jun 2026 09:01:42 +0000 (11:01 +0200)] 
7zip: Avoid unnecessary int64_t size_t casts

Use size_t for avail_in, avail_out and stream_in for ppmd streams.

The fields avail_in and avail_out values are set in function decompress
based on size_t variables (t_avail_in/t_avail_out) and eventually
written back. The stream_in field is only incremented.

The actual use case happens within ppmd_read to support situations in
which not enough bytes are available. In such cases, more bytes are read
on demand but not written into next_in.

In such cases, avail_in can turn negative and next_in can point outside
of its allocated memory area.

Since stream_in is always incremented by one, it won't overflow on real
hardware, given that size_t would address the whole available heap
space.

Make sure that avail_in never turns negative (which allows the size_t
usage) and also guarantee that t_avail_in will never wrap around,
leading to a huge "used" value.

As a bonus, __archive_read_ahead can be reliably called with a NULL
argument now, since no more casting occurs for second argument, which
was missing in the test.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days agoMerge pull request #3138 from datauwu/tar-ustar-pathname-fastpath
Dustin L. Howett [Fri, 12 Jun 2026 18:17:58 +0000 (13:17 -0500)] 
Merge pull request #3138 from datauwu/tar-ustar-pathname-fastpath

3 days agoMerge pull request #3140 from DHowett/dh/write-free-1
Tobias Stoeckmann [Fri, 12 Jun 2026 16:05:13 +0000 (18:05 +0200)] 
Merge pull request #3140 from DHowett/dh/write-free-1

test: remove one new instance of assertEqualIntA(...free...)

3 days agotest: remove one new instance of assertEqualIntA(...free...) 3140/head
Dustin L. Howett [Fri, 12 Jun 2026 15:30:13 +0000 (10:30 -0500)] 
test: remove one new instance of assertEqualIntA(...free...)

3 days agoMerge pull request #2865 from GeorgH93/read_zipx_encryption
Dustin L. Howett [Fri, 12 Jun 2026 15:28:45 +0000 (10:28 -0500)] 
Merge pull request #2865 from GeorgH93/read_zipx_encryption

Add support for reading encrypted zipx formats (bzip2, lzma, ppmd, xz, zstd)

3 days agoIntroduce zipx encryption handling for zstd compressed zip files 2865/head
GeorgH93 [Wed, 10 Jun 2026 19:35:48 +0000 (21:35 +0200)] 
Introduce zipx encryption handling for zstd compressed zip files

3 days agoIntroduce zipx encryption handling for bzip2 compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:35:20 +0000 (21:35 +0200)] 
Introduce zipx encryption handling for bzip2 compressed zip files

3 days agoIntroduce zipx encryption handling for lzma compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:34:27 +0000 (21:34 +0200)] 
Introduce zipx encryption handling for lzma compressed zip files

3 days agoIntroduce zipx encryption handling for xz compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:33:16 +0000 (21:33 +0200)] 
Introduce zipx encryption handling for xz compressed zip files

3 days agoIntroduce zipx encryption handling for ppmd compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:31:46 +0000 (21:31 +0200)] 
Introduce zipx encryption handling for ppmd compressed zip files

3 days agoAdd test for creating encrypted zip file with libarchive and reading it again with...
GeorgH93 [Wed, 10 Jun 2026 19:27:29 +0000 (21:27 +0200)] 
Add test for creating encrypted zip file with libarchive and reading it again with libarchive

3 days agoRefactor zip archive reader, by moving decryption related code blocks into their...
GeorgH93 [Wed, 10 Jun 2026 19:23:31 +0000 (21:23 +0200)] 
Refactor zip archive reader, by moving decryption related code blocks into their own functions to make them reusable for compression formats other than deflate

3 days agotar reader: avoid temporary buffer for empty-prefix ustar names 3138/head
data [Thu, 11 Jun 2026 19:36:33 +0000 (03:36 +0800)] 
tar reader: avoid temporary buffer for empty-prefix ustar names

For empty-prefix ustar entries, copy the fixed-width name field
directly into the archive entry instead of first building a temporary
archive_string.

This avoids a temporary buffer allocation and intermediate copy in the
common case. It also fixes a small fatal-error leak by freeing the
temporary prefix/name buffer before returning on pathname conversion
failure.

3 days agoMerge pull request #2923 from bililateral/pr-7zip-numfiles-oom
Tobias Stoeckmann [Fri, 12 Jun 2026 06:27:25 +0000 (08:27 +0200)] 
Merge pull request #2923 from bililateral/pr-7zip-numfiles-oom

7zip: sanity-check FilesInfo NumFiles before allocating entries

3 days agoMerge pull request #3105 from i1011/rar-unbounded-staticdata-fix
Dustin L. Howett [Fri, 12 Jun 2026 04:09:19 +0000 (23:09 -0500)] 
Merge pull request #3105 from i1011/rar-unbounded-staticdata-fix

rar: Add missing bound check for staticdata

3 days agoMerge pull request #3137 from stoeckmann/typos_style
Dustin L. Howett [Fri, 12 Jun 2026 04:05:03 +0000 (23:05 -0500)] 
Merge pull request #3137 from stoeckmann/typos_style

Fix minor non-functional issues

4 days agoMerge pull request #3136 from stoeckmann/counters
Dustin L. Howett [Thu, 11 Jun 2026 20:41:05 +0000 (15:41 -0500)] 
Merge pull request #3136 from stoeckmann/counters

Remove unneeded counters

4 days agocpio: Remove unneeded cast 3137/head
Tobias Stoeckmann [Thu, 11 Jun 2026 16:59:29 +0000 (18:59 +0200)] 
cpio: Remove unneeded cast

The variable l is uint64_t, the return type is uint64_t. Do not cast to
int64_t.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agoFix whitespace issues
Tobias Stoeckmann [Thu, 11 Jun 2026 16:59:18 +0000 (18:59 +0200)] 
Fix whitespace issues

No functional change

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agoFix typos in comments and documentation
Tobias Stoeckmann [Thu, 11 Jun 2026 16:58:19 +0000 (18:58 +0200)] 
Fix typos in comments and documentation

No functional change

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agofilters: Remove unneeded counters 3136/head
Tobias Stoeckmann [Thu, 11 Jun 2026 16:57:36 +0000 (18:57 +0200)] 
filters: Remove unneeded counters

These counters are written to, but they are never read. Remove them for
easier code audits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agoformats: Remove unneeded counters
Tobias Stoeckmann [Thu, 11 Jun 2026 16:56:59 +0000 (18:56 +0200)] 
formats: Remove unneeded counters

These counters are written to, but they are never read. Remove them for
easier code audits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 days agorar: Reject staticdatalen larger than VM memory 3105/head
i1011 [Thu, 11 Jun 2026 16:51:16 +0000 (00:51 +0800)] 
rar: Reject staticdatalen larger than VM memory

4 days agoMerge commit from fork
Tobias Stoeckmann [Thu, 11 Jun 2026 15:41:31 +0000 (17:41 +0200)] 
Merge commit from fork

unzip: reject absolute or traversing symlink targets

5 days agoRefactor the zip_winzip_aes_large test to support parameterized file ordering, file...
GeorgH93 [Wed, 10 Jun 2026 19:14:02 +0000 (21:14 +0200)] 
Refactor the zip_winzip_aes_large test to support parameterized file ordering, file mode and compression type

5 days ago7zip: sanity-check FilesInfo NumFiles before allocating entries 2923/head
bililateral [Wed, 18 Mar 2026 08:37:45 +0000 (16:37 +0800)] 
7zip: sanity-check FilesInfo NumFiles before allocating entries

5 days agoMerge pull request #3048 from legnaleurc/fix/rar-reset-lz-table
Dustin L. Howett [Wed, 10 Jun 2026 01:30:47 +0000 (20:30 -0500)] 
Merge pull request #3048 from legnaleurc/fix/rar-reset-lz-table

rar: reset low-distance state for new LZ tables

5 days agoMerge pull request #3047 from legnaleurc/fix/rar-recovery-record
Dustin L. Howett [Wed, 10 Jun 2026 01:26:31 +0000 (20:26 -0500)] 
Merge pull request #3047 from legnaleurc/fix/rar-recovery-record

rar: skip NEWSUB payloads without size cap

5 days agoMerge pull request #3132 from stoeckmann/lz4_double_free
Dustin L. Howett [Wed, 10 Jun 2026 01:14:28 +0000 (20:14 -0500)] 
Merge pull request #3132 from stoeckmann/lz4_double_free

lz4: Fix double-free on reallocation failure
Alternative version of https://github.com/libarchive/libarchive/pull/2945 which removes the test (which requires a modified malloc to actually fail the 4 MB allocation).

6 days agoMerge pull request #3034 from datauwu/master
Dustin L. Howett [Tue, 9 Jun 2026 22:00:55 +0000 (17:00 -0500)] 
Merge pull request #3034 from datauwu/master

6 days agoFix double-free in LZ4 filter on reallocation failure (CWE-415) 3132/head
isomorph-cyber [Wed, 25 Mar 2026 03:19:10 +0000 (23:19 -0400)] 
Fix double-free in LZ4 filter on reallocation failure (CWE-415)

lz4_allocate_out_block() frees state->out_block without NULLing
the pointer. If the subsequent malloc fails, the function returns
ARCHIVE_FATAL with a dangling pointer. lz4_filter_close() later
calls free(state->out_block) again, triggering a double-free.

Also, state->out_block_size was updated before checking if malloc
succeeded, leaving inconsistent metadata on failure.

Fix both lz4_allocate_out_block() and lz4_allocate_out_block_for_legacy():
- NULL the pointer immediately after free
- Move size update to after malloc succeeds
- Reset size to 0 on allocation failure

6 days ago7zip: reject malformed SubStreamsInfo metadata 3034/head
datauwu [Tue, 9 Jun 2026 19:10:27 +0000 (03:10 +0800)] 
7zip: reject malformed SubStreamsInfo metadata

Validate the accumulated unpack stream count before allocating
per-substream metadata.

Reject folders that declare multiple substreams without kSize metadata,
since the parser needs those sizes to describe the stream layout.

Drop the explicit digest zeroing loop. The arrays are allocated with
calloc(), so the entries are already initialized.

6 days ago7zip: add malformed SubStreamsInfo test
datauwu [Tue, 9 Jun 2026 19:10:27 +0000 (03:10 +0800)] 
7zip: add malformed SubStreamsInfo test

Add a 7z regression test for malformed SubStreamsInfo metadata that
declares more than one unpack stream without the kSize data needed to
describe those streams.

Store the archive as a .7z.uu file, matching the existing malformed
7z tests.

6 days agounzip: reject absolute or traversing symlink targets
Dustin L. Howett [Tue, 9 Jun 2026 16:16:02 +0000 (11:16 -0500)] 
unzip: reject absolute or traversing symlink targets

This is overly broad, and will reject some well-formed archives which
contain symlinks to trees which exist in the archive; however, this is
the best we can do without some rudimentary path parsing.

Fixes GHSA-q4gj-vh8c-67p8

6 days agoMerge pull request #2954 from ShelpAm/master
Dustin L. Howett [Tue, 9 Jun 2026 14:55:46 +0000 (09:55 -0500)] 
Merge pull request #2954 from ShelpAm/master

fix: zstd not found on Windows

6 days agoMerge pull request #2967 from bgilbert/deflate
Martin Matuška [Tue, 9 Jun 2026 06:40:07 +0000 (08:40 +0200)] 
Merge pull request #2967 from bgilbert/deflate

Fix `test_write_filter_gzip` on Ubuntu s390x

6 days agoMerge pull request #3131 from stoeckmann/rpm_fsm
Martin Matuška [Tue, 9 Jun 2026 06:35:23 +0000 (08:35 +0200)] 
Merge pull request #3131 from stoeckmann/rpm_fsm

rpm: Refactor filter

6 days agoMerge pull request #3128 from stoeckmann/into_fd
Martin Matuška [Tue, 9 Jun 2026 06:31:24 +0000 (08:31 +0200)] 
Merge pull request #3128 from stoeckmann/into_fd

Improve `archive_read_data_into_fd` with sparse files

6 days agoMerge pull request #3121 from stoeckmann/rar5_bytes_remaining
Martin Matuška [Tue, 9 Jun 2026 06:30:03 +0000 (08:30 +0200)] 
Merge pull request #3121 from stoeckmann/rar5_bytes_remaining

rar5: fix signed integer underflow in bytes_remaining

6 days agoMerge pull request #3120 from stoeckmann/archive_endian
Martin Matuška [Tue, 9 Jun 2026 06:29:23 +0000 (08:29 +0200)] 
Merge pull request #3120 from stoeckmann/archive_endian

Extend `archive_endian.h` usage

6 days agoMerge pull request #3098 from stoeckmann/filter_read_ahead
Martin Matuška [Tue, 9 Jun 2026 06:28:38 +0000 (08:28 +0200)] 
Merge pull request #3098 from stoeckmann/filter_read_ahead

filters: Simplify `__archive_read_filter_ahead` use

6 days agoMerge pull request #3119 from stoeckmann/7zip_u32_oflow
Martin Matuška [Tue, 9 Jun 2026 06:27:58 +0000 (08:27 +0200)] 
Merge pull request #3119 from stoeckmann/7zip_u32_oflow

7zip: Fix range check in get_pe_sfx_offset

6 days agoMerge pull request #3115 from stoeckmann/gzip_writer_mem
Martin Matuška [Tue, 9 Jun 2026 06:26:54 +0000 (08:26 +0200)] 
Merge pull request #3115 from stoeckmann/gzip_writer_mem

gzip: Fix OOB in writer with huge filename

6 days agoMerge pull request #3114 from stoeckmann/open_oob
Martin Matuška [Tue, 9 Jun 2026 06:25:51 +0000 (08:25 +0200)] 
Merge pull request #3114 from stoeckmann/open_oob

Fix OOB in `archive_read_open_filenames_w` on some systems

6 days agoMerge pull request #3113 from stoeckmann/fflags_strcpy
Martin Matuška [Tue, 9 Jun 2026 06:25:10 +0000 (08:25 +0200)] 
Merge pull request #3113 from stoeckmann/fflags_strcpy

7zip/rar5: Simplify file attribute handling

6 days agoMerge pull request #3108 from stoeckmann/windows_legacy
Martin Matuška [Tue, 9 Jun 2026 06:24:24 +0000 (08:24 +0200)] 
Merge pull request #3108 from stoeckmann/windows_legacy

Reduce Windows legacy support

6 days agoMerge pull request #3116 from stoeckmann/hardening
Dustin L. Howett [Tue, 9 Jun 2026 00:29:04 +0000 (19:29 -0500)] 
Merge pull request #3116 from stoeckmann/hardening

This PR does not fix any reachable issue, but fixes the code in question nonetheless to prevent regressions in the future:

- Do not call `archive_copy_error` after `archive_read_free` to prevent a user after free bug
- Reset `vtable` to `NULL` to prevent `close` from being called after filter initialization error, since `data` is already freed and set to `NULL`, preventing a `NULL` pointer dereference

6 days agoMerge pull request #3021 from chnzzh/fix/iso9660-ce-loop
Dustin L. Howett [Tue, 9 Jun 2026 00:06:43 +0000 (19:06 -0500)] 
Merge pull request #3021 from chnzzh/fix/iso9660-ce-loop

iso9660: fix infinite loop on self-referencing CE entry

7 days agoMerge pull request #3127 from shxz9u/fix-callback-data-realloc
Dustin L. Howett [Mon, 8 Jun 2026 20:39:07 +0000 (15:39 -0500)] 
Merge pull request #3127 from shxz9u/fix-callback-data-realloc

Avoid updating allocation state before realloc succeeds

7 days agoMerge pull request #3126 from stoeckmann/shar
Dustin L. Howett [Mon, 8 Jun 2026 20:30:26 +0000 (15:30 -0500)] 
Merge pull request #3126 from stoeckmann/shar

shar: Check `archive_entry_clone` result

7 days agoMerge pull request #3125 from stoeckmann/disk_clone
Dustin L. Howett [Mon, 8 Jun 2026 20:29:48 +0000 (15:29 -0500)] 
Merge pull request #3125 from stoeckmann/disk_clone

Check allocation in `_archive_write_disk_header`

7 days agoMerge pull request #3124 from stoeckmann/entry_mem
Dustin L. Howett [Mon, 8 Jun 2026 20:28:01 +0000 (15:28 -0500)] 
Merge pull request #3124 from stoeckmann/entry_mem

entry_link_resolver: Improve memory handling

7 days agoMerge pull request #3123 from stoeckmann/cab_remaining
Dustin L. Howett [Mon, 8 Jun 2026 20:27:04 +0000 (15:27 -0500)] 
Merge pull request #3123 from stoeckmann/cab_remaining

cab: Simplify `cab_read_ahead_remaining`

7 days agoMerge pull request #3122 from stoeckmann/into_buffer
Dustin L. Howett [Mon, 8 Jun 2026 20:26:25 +0000 (15:26 -0500)] 
Merge pull request #3122 from stoeckmann/into_buffer

Remove `archive_read_data_into_buffer` comment

7 days agoMerge pull request #3117 from i1011/iso9660-null-deref-fix
Dustin L. Howett [Mon, 8 Jun 2026 20:25:59 +0000 (15:25 -0500)] 
Merge pull request #3117 from i1011/iso9660-null-deref-fix

iso9660: Fix null dereference in set_directory_record_rr

7 days agoopen: Fix OOB in archive_read_open_filenames_w 3114/head
Tobias Stoeckmann [Wed, 3 Jun 2026 20:12:03 +0000 (22:12 +0200)] 
open: Fix OOB in archive_read_open_filenames_w

If a system with sizeof(wchar_t)=2 (e.g. Cygwin) tries to convert a wide
character string into a multi byte string representation, it
precalculates the required length with sizeof(wchar_t) instead of
MB_LEN_MAX. This can lead to short memory allocation for filenames which
have a shorter representation in wchar_t than in UTF-8.

Resolves GHSA-crm5-q56g-xw29.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agoopen: Check OOB in archive_read_open_filenames_w
Tobias Stoeckmann [Wed, 3 Jun 2026 20:10:35 +0000 (22:10 +0200)] 
open: Check OOB in archive_read_open_filenames_w

A system with sizeof(wchar_t)=2 (Cygwin on Windows) can trigger an out
of boundary write in archive_read_open_filenames_w when converting the
wide character string into a multi byte string.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agorpm: Refactor filter 3131/head
Tobias Stoeckmann [Mon, 8 Jun 2026 18:39:39 +0000 (20:39 +0200)] 
rpm: Refactor filter

The current finite state machine carefully handles short reads, i.e. the
loop can enter as often as needed until enough bytes arrive for the
current state to perform its actions.

This can be simplified by relying on __archive_filter_read_ahead to
return the amount of bytes actually needed. I assume that this did not
happen in the original code due to its age (2009) and evolution of
libarchive's internals over time.

Also, headers are only skipped at the beginning. As soon as the reader
starts returning data (ST_ARCHIVE reached), the filter pretty much
becomes a pass-through filter.

Split the initial lead and header skipping into its own function and
only keep track if the initial skipping was performed or not. This
greatly simplifies the reader function.

Also, it avoids book keeping of internal states and "total_in" tracking,
which I don't have to properly audit for edge cases anymore.

Last but not least, this refactoring properly reports truncated streams
now.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agoAvoid updating allocation state before realloc succeeds 3127/head
magnolia [Sun, 7 Jun 2026 23:37:54 +0000 (08:37 +0900)] 
Avoid updating allocation state before realloc succeeds

8 days agoread_data_into_fd: Allocate nulls on demand 3128/head
Tobias Stoeckmann [Sun, 7 Jun 2026 15:20:58 +0000 (17:20 +0200)] 
read_data_into_fd: Allocate nulls on demand

Allocate nulls only when needed, i.e. when sparse files are encountered.
This removes another malloc call from regular use cases.

While at it, call archive_set_error in case of allocation failure for
better error messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoread_data_into_fd: Perform final seek check
Tobias Stoeckmann [Sun, 7 Jun 2026 14:47:20 +0000 (16:47 +0200)] 
read_data_into_fd: Perform final seek check

Try to detect if writing data to correct position failed due to being
in append mode.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoread_data_into_fd: Print correct error code
Tobias Stoeckmann [Sun, 7 Jun 2026 14:44:36 +0000 (16:44 +0200)] 
read_data_into_fd: Print correct error code

If lseek fails to seek to correct position, e.g. because the descriptor
is in append mode, do not use errno because it's not set.

In such a case, fall back to ARCHIVE_ERRNO_MISC.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoshar: Check archive_entry_clone result 3126/head
Tobias Stoeckmann [Sun, 7 Jun 2026 13:52:45 +0000 (15:52 +0200)] 
shar: Check archive_entry_clone result

Properly handle allocation failures.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoCheck allocation in _archive_write_disk_header 3125/head
Tobias Stoeckmann [Sun, 7 Jun 2026 13:49:46 +0000 (15:49 +0200)] 
Check allocation in _archive_write_disk_header

The POSIX and Windows code did not check the result of
archive_entry_clone. Handle this error condition properly.

While at it, unify POSIX and Windows code a bit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoentry: Use size_t for element count 3124/head
Tobias Stoeckmann [Sun, 7 Jun 2026 13:43:13 +0000 (15:43 +0200)] 
entry: Use size_t for element count

LLP64 could theoretically overflow the 32 bit counter. It still needs a
lot memory to achieve this, but let's better be safe than sorry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoentry: Check allocation in insert_entry
Tobias Stoeckmann [Sun, 7 Jun 2026 13:42:29 +0000 (15:42 +0200)] 
entry: Check allocation in insert_entry

Check if allocation succeded. If not, properly handle the error instead
of eventually performing a NULL pointer dereference.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agocab: Simplify cab_read_ahead_remaining 3123/head
Tobias Stoeckmann [Sun, 7 Jun 2026 13:19:50 +0000 (15:19 +0200)] 
cab: Simplify cab_read_ahead_remaining

We do not have to guess the amount of remaining bytes, since
archive_read_ahead returns the information.

Simplify the function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoRemove archive_read_data_into_buffer comment 3122/head
Tobias Stoeckmann [Sun, 7 Jun 2026 13:15:33 +0000 (15:15 +0200)] 
Remove archive_read_data_into_buffer comment

The function has been removed in 2011 with commit
fe9b86254d66411b6bf267a02236d4672258b61b. Remove the comment as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agorar5: fix integer underflow in bytes_remaining 3121/head
00redbeer [Sun, 7 Jun 2026 12:23:25 +0000 (14:23 +0200)] 
rar5: fix integer underflow in bytes_remaining

A malformed RAR5 archive with data_size=1 forces bytes_remaining
(ssize_t) to wrap to -2 when a compressed block header consumes
to_skip=3 bytes (CWE-191). That negative value is then implicitly
cast to size_t ~0 inside malloc(), requesting a ~16-exabyte
allocation — confirmed heap buffer overflow via ASAN/UBSan on a
48-byte crafted archive requiring no authentication.

Three guards added to archive_read_support_format_rar5.c:

1. Reject data_size > SSIZE_MAX before assigning to bytes_remaining
   (CWE-195, unsafe unsigned-to-signed conversion)

2. Reject to_skip > bytes_remaining in process_block() before the
   subtraction — this is the primary fix for the underflow (CWE-191)

3. Change cur_block_size == 0 to cur_block_size <= 0 in merge_block()
   as defense-in-depth so that any negative bytes_remaining reaching
   read_ahead() is caught before it becomes a malloc size (CWE-122)

8 days agorar5: check integer overflow in bytes_remaining
00redbeer [Sun, 7 Jun 2026 12:14:34 +0000 (14:14 +0200)] 
rar5: check integer overflow in bytes_remaining

A malformed RAR5 archive with data_size=1 forces bytes_remaining
(ssize_t) to wrap to -2 when a compressed block header consumes
to_skip=3 bytes (CWE-191). That negative value is then implicitly
cast to size_t ~0 inside malloc(), requesting a ~16-exabyte
allocation — confirmed heap buffer overflow via ASAN/UBSan on a
48-byte crafted archive requiring no authentication.

Reproducer: 48-byte crafted RAR5 archive; ASAN confirms
"allocation-size-too-big 0xfffffffffffffffe".

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoiso9660: Reserve more space in record to avoid null deref 3117/head
i1011 [Sun, 7 Jun 2026 12:50:42 +0000 (20:50 +0800)] 
iso9660: Reserve more space in record to avoid null deref

8 days agoiso9660: Add symlink name length enumeration test
i1011 [Sun, 7 Jun 2026 12:50:31 +0000 (20:50 +0800)] 
iso9660: Add symlink name length enumeration test

8 days agoshar: Use archive_endian.h function 3120/head
Tobias Stoeckmann [Thu, 4 Jun 2026 19:41:12 +0000 (21:41 +0200)] 
shar: Use archive_endian.h function

Make it easier to verify code by re-using already existing function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agorar5: Use archive_endian.h functions
Tobias Stoeckmann [Thu, 4 Jun 2026 18:10:41 +0000 (20:10 +0200)] 
rar5: Use archive_endian.h functions

Make it easier to verify code by re-using already existing functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days ago7zip: Use archive_endian.h functions
Tobias Stoeckmann [Thu, 4 Jun 2026 18:02:51 +0000 (20:02 +0200)] 
7zip: Use archive_endian.h functions

Make it easier to verify code by re-using already existing functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoiso9660: Use archive_endian.h functions
Tobias Stoeckmann [Thu, 4 Jun 2026 17:45:40 +0000 (19:45 +0200)] 
iso9660: Use archive_endian.h functions

Make it easier to verify code by re-using already existing functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agogzip: Use archive_endian.h functions
Tobias Stoeckmann [Thu, 4 Jun 2026 17:30:58 +0000 (19:30 +0200)] 
gzip: Use archive_endian.h functions

Make it easier to verify code by re-using already existing functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agocpio: Use archive_endian.h functions
Tobias Stoeckmann [Thu, 4 Jun 2026 16:34:46 +0000 (18:34 +0200)] 
cpio: Use archive_endian.h functions

Make it easier to verify code be re-using already existing functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 days agoendian: Add new 24 bit functions
Tobias Stoeckmann [Thu, 4 Jun 2026 16:04:36 +0000 (18:04 +0200)] 
endian: Add new 24 bit functions

Sometimes, 24 bit operations are needed. Enough users exist that moving
this into archive_endian.h is worth it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days ago7zip: Fix range check in get_pe_sfx_offset 3119/head
Tobias Stoeckmann [Sat, 6 Jun 2026 20:47:00 +0000 (22:47 +0200)] 
7zip: Fix range check in get_pe_sfx_offset

Fix an unsigned integer overflow in get_pe_sfx_offset to properly
address the correct section.

Reported by shxz9u.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days agoxz: Properly clean up resources on error path 3116/head
Tobias Stoeckmann [Sat, 6 Jun 2026 09:40:19 +0000 (11:40 +0200)] 
xz: Properly clean up resources on error path

If vtable is not set to NULL, close function would be called during
shutdown. Since data is already freed and set to NULL, this would lead
to a NULL pointer dereference later on.

The called library functions should never fail though, so this is a
purely defensive measure against future lzma changes.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days agomatch: Prevent currently unreachable UAF
Tobias Stoeckmann [Sat, 6 Jun 2026 09:37:27 +0000 (11:37 +0200)] 
match: Prevent currently unreachable UAF

If archive_read_next_header in add_pattern_from_file would ever return
anything but ARCHIVE_OK or ARCHIVE_EOF, a use after free would occur
when copying error information.

Since this is impossible with current setup (format raw without any
further filter, thus only open_filename code), this change is a purely
defensive measure against future changes.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
11 days agogzip: Fix OOB with huge filenames 3115/head
Tobias Stoeckmann [Thu, 4 Jun 2026 20:13:45 +0000 (22:13 +0200)] 
gzip: Fix OOB with huge filenames

If a filename is larger than INT_MAX, an out of boundary write could
occur on 64 bit systems. Fix data types and ignore such huge file names.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
11 days agogzip: Properly handle option strdup failure
Tobias Stoeckmann [Thu, 4 Jun 2026 19:52:58 +0000 (21:52 +0200)] 
gzip: Properly handle option strdup failure

If the original name cannot be duplicated, return ARCHIVE_FAILED instead
of ARCHIVE_WARN. The latter implies that the option is unknown, which is
not the case.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
11 days agogzip: Turn total_in unsigned
Tobias Stoeckmann [Thu, 4 Jun 2026 19:41:55 +0000 (21:41 +0200)] 
gzip: Turn total_in unsigned

All arithmetical operations are unsigned, and it makes sense to keep it
unsigned: The total_in value is written at the end of the stream and if
the value overflows, it's pretty much expected to be % UINT32_MAX.

Very unlikely that int64_t will ever overflow, but the fix is cheap.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agocpio: Simplify WINAPI_FAMILIY_PARTITION check 3108/head
Tobias Stoeckmann [Wed, 3 Jun 2026 18:33:37 +0000 (20:33 +0200)] 
cpio: Simplify WINAPI_FAMILIY_PARTITION check

The macro is defined in archive_windows.h if missing.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agowindows: Simplify la_CreateSymbolicLinkW
Tobias Stoeckmann [Tue, 2 Jun 2026 19:02:59 +0000 (21:02 +0200)] 
windows: Simplify la_CreateSymbolicLinkW

The CreateSymbolicLinkW function is available since 0x0600 and is also
part of the Nano Server APIs. On earlier systems, don't even try.
Otherwise use it directly to simplify code.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days ago7zip/rar5: Simplify file attribute handling 3113/head
Tobias Stoeckmann [Wed, 3 Jun 2026 18:47:22 +0000 (20:47 +0200)] 
7zip/rar5: Simplify file attribute handling

- Use a stack array for 22 bytes
- Entering the if-branch already implies that we will add data
- Use snprintf instead of strcpy

Even though snprintf is slower than strcpy, it's easier to verify and
since nobody complained so far about the malloc overhead, this should be
okay (for now).

As a bonus, this code cannot fail anymore, which previously meant that
file attributes were silently ignored.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agowindows: Remove pre Windows XP support code
Tobias Stoeckmann [Tue, 2 Jun 2026 19:01:23 +0000 (21:01 +0200)] 
windows: Remove pre Windows XP support code

The oldest version we support is 0x0502, while _WIN32_WINNT_XP is
0x0500. Drop support code for even older versions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agoMerge pull request #3039 from dnelson-1901/manpage-fixes
Dustin L. Howett [Wed, 3 Jun 2026 05:35:22 +0000 (22:35 -0700)] 
Merge pull request #3039 from dnelson-1901/manpage-fixes

12 days agoMerge pull request #3109 from stoeckmann/windows_concurrency
Dustin L. Howett [Wed, 3 Jun 2026 05:33:10 +0000 (22:33 -0700)] 
Merge pull request #3109 from stoeckmann/windows_concurrency

12 days agoMerge pull request #3112 from stoeckmann/windows_partition
Dustin L. Howett [Wed, 3 Jun 2026 04:58:40 +0000 (21:58 -0700)] 
Merge pull request #3112 from stoeckmann/windows_partition