]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
6 hours agoMerge commit from fork master
Dustin L. Howett [Mon, 29 Jun 2026 20:30:34 +0000 (15:30 -0500)] 
Merge commit from fork

windows: fix a number of symlink handling issues and enable tests

7 hours agoMerge pull request #3205 from DHowett/assert-mem-obo
Tobias Stoeckmann [Mon, 29 Jun 2026 20:11:18 +0000 (22:11 +0200)] 
Merge pull request #3205 from DHowett/assert-mem-obo

Fix two more off-by-ones calling assertEqualMem

8 hours agoMerge pull request #3204 from stoeckmann/cab_oob_handling
Dustin L. Howett [Mon, 29 Jun 2026 19:13:07 +0000 (14:13 -0500)] 
Merge pull request #3204 from stoeckmann/cab_oob_handling

8 hours agozip: compare entire file contents (assert_mem off by one) 3205/head
Dustin L. Howett [Mon, 29 Jun 2026 18:56:05 +0000 (13:56 -0500)] 
zip: compare entire file contents (assert_mem off by one)

8 hours agoustar: fix length of ustar header needle
Dustin L. Howett [Mon, 29 Jun 2026 18:55:50 +0000 (13:55 -0500)] 
ustar: fix length of ustar header needle

9 hours agocab: Remove obsolete safety checks 3204/head
Tobias Stoeckmann [Mon, 29 Jun 2026 17:55:08 +0000 (19:55 +0200)] 
cab: Remove obsolete safety checks

Commit e1f890dc62f7931d971e2483efd8a3d30a98b1f4 fixed the underlying
root cause of these OOB checks: If a header is invalid and ARCHIVE_FATAL
is returned, do not allow data reads anymore.

The checks while reading CFDATA already looked rather off, since the
check exists in header parser and the value is never updated, but
prevent worst case scenario.

Keep the tests as regression tests if archive_read.c is modified again.

This makes the code easier to read and audit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
10 hours agoMerge pull request #3200 from datauwu/zip-fix-compare-full-contents
Dustin L. Howett [Mon, 29 Jun 2026 17:04:44 +0000 (12:04 -0500)] 
Merge pull request #3200 from datauwu/zip-fix-compare-full-contents

zip: compare full file3 contents in tests

10 hours agoMerge pull request #3199 from datauwu/7zip-redundant-header-checks
Dustin L. Howett [Mon, 29 Jun 2026 17:04:01 +0000 (12:04 -0500)] 
Merge pull request #3199 from datauwu/7zip-redundant-header-checks

7zip: remove redundant read header checks

10 hours agoMerge pull request #3201 from datauwu/tests-fix-charset-labels
Dustin L. Howett [Mon, 29 Jun 2026 16:31:52 +0000 (11:31 -0500)] 
Merge pull request #3201 from datauwu/tests-fix-charset-labels

tests: fix incorrect charset labels

10 hours agoMerge pull request #3203 from libarchive/dependabot/github_actions/all-actions-fc272564ab
Dustin L. Howett [Mon, 29 Jun 2026 16:31:09 +0000 (11:31 -0500)] 
Merge pull request #3203 from libarchive/dependabot/github_actions/all-actions-fc272564ab

CI: Bump acj/freebsd-firecracker-action from 0.10.0 to 0.10.1 in the all-actions group

10 hours agoMerge pull request #3187 from nvmb3r/rar5-unpacked-size-limit
Dustin L. Howett [Mon, 29 Jun 2026 16:30:15 +0000 (11:30 -0500)] 
Merge pull request #3187 from nvmb3r/rar5-unpacked-size-limit

rar5: reject streams that exceed the declared unpacked size

10 hours agoMerge pull request #3194 from uchiha-bug-hunter/iso9660-zf-oob-read
Dustin L. Howett [Mon, 29 Jun 2026 16:29:28 +0000 (11:29 -0500)] 
Merge pull request #3194 from uchiha-bug-hunter/iso9660-zf-oob-read

iso9660: fix OOB read in parse_rockridge_ZF1 on short ZF entry

11 hours agoCI: Bump acj/freebsd-firecracker-action in the all-actions group 3203/head
dependabot[bot] [Mon, 29 Jun 2026 16:13:00 +0000 (16:13 +0000)] 
CI: Bump acj/freebsd-firecracker-action in the all-actions group

Bumps the all-actions group with 1 update: [acj/freebsd-firecracker-action](https://github.com/acj/freebsd-firecracker-action).

Updates `acj/freebsd-firecracker-action` from 0.10.0 to 0.10.1
- [Release notes](https://github.com/acj/freebsd-firecracker-action/releases)
- [Commits](https://github.com/acj/freebsd-firecracker-action/compare/ff79eb955fd19c697a708a02834995e47a6e58ed...da029f050a7a2535fce96385727cf3d5768bd8bf)

---
updated-dependencies:
- dependency-name: acj/freebsd-firecracker-action
  dependency-version: 0.10.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
11 hours agoMerge pull request #3192 from stoeckmann/ar_integers
Dustin L. Howett [Mon, 29 Jun 2026 15:36:22 +0000 (10:36 -0500)] 
Merge pull request #3192 from stoeckmann/ar_integers

12 hours agoar: Adjust style and fix comment grammar 3192/head
Tobias Stoeckmann [Sun, 28 Jun 2026 10:01:02 +0000 (12:01 +0200)] 
ar: Adjust style and fix comment grammar

Use style most often seen in other format parsers.
While at it, fix grammar in comment.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 hours agoar: Simplify error handling in _ar_read_header
Tobias Stoeckmann [Sun, 28 Jun 2026 09:51:52 +0000 (11:51 +0200)] 
ar: Simplify error handling in _ar_read_header

The comment states that a warning should be returned, but
97f964e3e0ce3ae34bfb4c366a37ba7c0d9610a6 explicitly changed that to
fatal. Adjust the comment and remove unneeded function call.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 hours agoar: Simplify _ar_read_header cases
Tobias Stoeckmann [Sun, 28 Jun 2026 09:42:05 +0000 (11:42 +0200)] 
ar: Simplify _ar_read_header cases

Symbol tables are not treated specially. Clarify that by merely
mentioning them in a comment.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 hours agoar: Set filetype only once
Tobias Stoeckmann [Sun, 28 Jun 2026 09:32:52 +0000 (11:32 +0200)] 
ar: Set filetype only once

All entries in ar are regular files. Set this information only once to
simplify code audits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 hours agoar: Simplify ar_parse_common_header usage
Tobias Stoeckmann [Sun, 28 Jun 2026 09:40:55 +0000 (11:40 +0200)] 
ar: Simplify ar_parse_common_header usage

The function ar_parse_common_header can be called at exactly one
position in _ar_read_header, since it parses common information.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 hours agoar: Simplify __archive_read_consume usage
Tobias Stoeckmann [Sun, 28 Jun 2026 09:19:04 +0000 (11:19 +0200)] 
ar: Simplify __archive_read_consume usage

The __archive_read_consume function is binary: Either all bytes are
consumed or a failure occurred. No partial consumption can occur.

Simplify its calls to clarify this.

While at it, adjust style of callers as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
17 hours agotests: fix incorrect charset labels 3201/head
datauwu [Mon, 29 Jun 2026 09:57:32 +0000 (17:57 +0800)] 
tests: fix incorrect charset labels

Several filename encoding tests were copied from KOI8-R or EUC-JP
cases, but now use CP1251 or CP932/SJIS instead.

Update skip messages, conversion messages, and comments to match the
locales and byte sequences used by the tests.

Also fix a typo in an EUC-JP ZIP filename skip message.

17 hours agozip: compare full file3 contents in tests 3200/head
data [Mon, 29 Jun 2026 09:41:22 +0000 (17:41 +0800)] 
zip: compare full file3 contents in tests

The file3_deflate payload is written and read as 5 bytes, but the test
only compared the first 4 bytes. Compare the full payload.

17 hours ago7zip: remove redundant read header checks 3199/head
data [Mon, 29 Jun 2026 09:10:11 +0000 (17:10 +0800)] 
7zip: remove redundant read header checks

archive_read_format_7zip_read_header() already returns before this
point if zip_entry is NULL. The folder pointer is also assigned from an
in-bounds folder array entry, so the extra NULL checks are redundant.

The later DONT_KNOW reset is redundant as well, since the same state is
handled earlier in the function. Remove the dead checks without changing
the encryption detection logic.

21 hours agoiso9660: check ZF entry length before reading data bytes 3194/head
Kaif Khan [Sun, 28 Jun 2026 15:18:29 +0000 (20:48 +0530)] 
iso9660: check ZF entry length before reading data bytes

21 hours agoiso9660: add regression test for short ZF entry over-read
Kaif Khan [Sun, 28 Jun 2026 15:18:25 +0000 (20:48 +0530)] 
iso9660: add regression test for short ZF entry over-read

25 hours agorar5: reject streams exceeding unpacked size 3187/head
nvmb3r [Mon, 29 Jun 2026 00:35:16 +0000 (17:35 -0700)] 
rar5: reject streams exceeding unpacked size

26 hours agorar5: add unpacked-size regression test
nvmb3r [Mon, 29 Jun 2026 00:35:16 +0000 (17:35 -0700)] 
rar5: add unpacked-size regression test

30 hours agoMerge pull request #3197 from stoeckmann/mtree_cast
Dustin L. Howett [Sun, 28 Jun 2026 20:41:48 +0000 (15:41 -0500)] 
Merge pull request #3197 from stoeckmann/mtree_cast

mtree: Fix integer overflow on 32 bit systems

31 hours agomtree: Fix integer overflow on 32 bit systems 3197/head
Tobias Stoeckmann [Sun, 28 Jun 2026 20:05:18 +0000 (22:05 +0200)] 
mtree: Fix integer overflow on 32 bit systems

If a file close to SSIZE_MAX in size is mapped into memory and checked
for mtree, a signed integer overflow could occur.

While this this generally harmless and the scenario very unlikely, fix
the issue with a proper cast.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
37 hours agoMerge pull request #3196 from datauwu/7zip-redundant-per-entry-setup
Dustin L. Howett [Sun, 28 Jun 2026 14:14:48 +0000 (09:14 -0500)] 
Merge pull request #3196 from datauwu/7zip-redundant-per-entry-setup

37 hours agoMerge pull request #3193 from datauwu/zip-harden-test-cleanup-assertion
Dustin L. Howett [Sun, 28 Jun 2026 13:30:25 +0000 (08:30 -0500)] 
Merge pull request #3193 from datauwu/zip-harden-test-cleanup-assertion

37 hours agoMerge pull request #3191 from stoeckmann/xattr_malloc
Dustin L. Howett [Sun, 28 Jun 2026 13:29:11 +0000 (08:29 -0500)] 
Merge pull request #3191 from stoeckmann/xattr_malloc

37 hours ago7zip: remove redundant per-entry setup 3196/head
data [Sun, 28 Jun 2026 13:28:15 +0000 (21:28 +0800)] 
7zip: remove redundant per-entry setup

`archive_read_format_7zip_read_header()` initialized `entry_crc32` with
`crc32(0, NULL, 0)`, which is equivalent to zero for this accumulator.

The same function also formatted the constant string `"7-Zip"` into an
internal buffer for every entry, then assigned it as the archive format name.
The format name can be set directly to the constant string, so the extra
buffer and per-entry `snprintf()` are unnecessary.

Remove the unused buffer and redundant per-entry work.

40 hours agozip: harden test cleanup assertion 3193/head
data [Sun, 28 Jun 2026 10:43:13 +0000 (18:43 +0800)] 
zip: harden test cleanup assertion

assertEqualIntA() uses the archive pointer to print archive error details
when the assertion fails. Passing `a` while the asserted expression is
`archive_free(a)` can make the failure path inspect the archive after it has
already been freed.

41 hours agoar: Use correct data types
Tobias Stoeckmann [Sun, 28 Jun 2026 10:03:34 +0000 (12:03 +0200)] 
ar: Use correct data types

Use int64_t for entry/file sizes.
Use size_t for sizes in heap.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
42 hours agoxattr: Treat memory allocation failure as error 3191/head
Tobias Stoeckmann [Sun, 28 Jun 2026 08:43:31 +0000 (10:43 +0200)] 
xattr: Treat memory allocation failure as error

Do not silently truncate values if allocation fails.

Reported by ysf.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 days agodisk (win32): do not promote ENOENT to EPERM in CreateSymbolicLinkW
Dustin L. Howett [Fri, 26 Jun 2026 15:16:15 +0000 (10:16 -0500)] 
disk (win32): do not promote ENOENT to EPERM in CreateSymbolicLinkW

2 days agodisk (win32): disallow hard links to symlinks
Dustin L. Howett [Fri, 26 Jun 2026 14:45:35 +0000 (09:45 -0500)] 
disk (win32): disallow hard links to symlinks

2 days agodisk (win32): invalidate the safe path cache when we write a symlink
Dustin L. Howett [Fri, 26 Jun 2026 13:45:58 +0000 (08:45 -0500)] 
disk (win32): invalidate the safe path cache when we write a symlink

2 days agodisk (win32): when caching a path as symlink-safe, only cache the parent
Dustin L. Howett [Fri, 26 Jun 2026 13:45:58 +0000 (08:45 -0500)] 
disk (win32): when caching a path as symlink-safe, only cache the parent

We used to cache the entire target path, which presented a problem when
we used that target path to write a symlink. Future archive entries
could write "through" that symlink because we cached it as safe.

2 days agodisk (win32): lift check_symlinks' logic into ...by_path
Dustin L. Howett [Fri, 26 Jun 2026 14:45:17 +0000 (09:45 -0500)] 
disk (win32): lift check_symlinks' logic into ...by_path

2 days agodisk (win32): remove 'a' parameter from file_information
Dustin L. Howett [Fri, 26 Jun 2026 14:37:57 +0000 (09:37 -0500)] 
disk (win32): remove 'a' parameter from file_information

2 days agodisk (win32): use the provided path for CreateFile
Dustin L. Howett [Fri, 26 Jun 2026 14:36:33 +0000 (09:36 -0500)] 
disk (win32): use the provided path for CreateFile

2 days agotest: light up the secure746 (hardlink + symlink) tests on Windows
Dustin L. Howett [Fri, 26 Jun 2026 14:47:20 +0000 (09:47 -0500)] 
test: light up the secure746 (hardlink + symlink) tests on Windows

2 days agotest: add a clarifying comment to secure745
Dustin L. Howett [Fri, 26 Jun 2026 14:46:39 +0000 (09:46 -0500)] 
test: add a clarifying comment to secure745

2 days agotest: light up the secure744 (deep nested symlinks) tests on Windows
Dustin L. Howett [Fri, 26 Jun 2026 15:17:02 +0000 (10:17 -0500)] 
test: light up the secure744 (deep nested symlinks) tests on Windows

2 days agotest: add a variant of the secure tests for windows
Dustin L. Howett [Fri, 26 Jun 2026 14:46:23 +0000 (09:46 -0500)] 
test: add a variant of the secure tests for windows

2 days agoMerge pull request #3188 from cyphercodes/fix-3151-empty-pax-headers
Tim Kientzle [Sat, 27 Jun 2026 16:03:47 +0000 (09:03 -0700)] 
Merge pull request #3188 from cyphercodes/fix-3151-empty-pax-headers

Reject empty pax extended headers

2 days agoReject empty pax extended headers 3188/head
cyphercodes [Sat, 27 Jun 2026 15:13:07 +0000 (18:13 +0300)] 
Reject empty pax extended headers

2 days agoMerge pull request #3185 from stoeckmann/7zip_integers
Tobias Stoeckmann [Sat, 27 Jun 2026 14:57:10 +0000 (16:57 +0200)] 
Merge pull request #3185 from stoeckmann/7zip_integers

7zip: Improve integer handling

2 days agoMerge pull request #3167 from stoeckmann/unzip_windows
Tobias Stoeckmann [Sat, 27 Jun 2026 14:56:53 +0000 (16:56 +0200)] 
Merge pull request #3167 from stoeckmann/unzip_windows

unzip: Add Windows port

3 days ago7zip: Fix style and typos 3185/head
Tobias Stoeckmann [Thu, 25 Jun 2026 21:04:57 +0000 (23:04 +0200)] 
7zip: Fix style and typos

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Move files_info_numfiles_is_sane body
Tobias Stoeckmann [Thu, 25 Jun 2026 20:46:39 +0000 (22:46 +0200)] 
7zip: Move files_info_numfiles_is_sane body

Declare and define files_info_numfiles_is_sane like all other static
functions in this file.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Do not store unused values
Tobias Stoeckmann [Thu, 25 Jun 2026 20:12:42 +0000 (22:12 +0200)] 
7zip: Do not store unused values

If values are only parsed and verified but not used later on, skip field
assignments. This reduces amount of fields to audit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Check skip in setup_decode_folder
Tobias Stoeckmann [Thu, 25 Jun 2026 19:33:58 +0000 (21:33 +0200)] 
7zip: Check skip in setup_decode_folder

Make sure that all bytes are actually skipped. Normally, the result can
be ignored because the bytes were read previously. Here, more bytes than
previously read will be skipped.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Fix BZ2/DEFLATE with huge input files
Tobias Stoeckmann [Thu, 25 Jun 2026 19:06:42 +0000 (21:06 +0200)] 
7zip: Fix BZ2/DEFLATE with huge input files

If more than UINT_MAX byte are available, e.g. if a very large archive
is mapped into memory, the BZ2/DEFLATE avail_in/avail_out values are
truncated.

Set to maximum allowed value in such cases.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Simplify decode_encoded_header_info
Tobias Stoeckmann [Thu, 25 Jun 2026 18:58:13 +0000 (20:58 +0200)] 
7zip: Simplify decode_encoded_header_info

With correct data types in place, simplify the overflow check by using
checked arithmetic and simple comparison.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Use correct data types
Tobias Stoeckmann [Thu, 25 Jun 2026 18:34:30 +0000 (20:34 +0200)] 
7zip: Use correct data types

Follow idea of internal libarchive APIs:

- File offsets and sizes are int64_t
- Memory offsets and sizes are size_t

Also use correct data types for iterator variables.

This refactoring also makes parse_7zip_uint64 obsolete by turning it
into parse_7zip_int64.

Resolves GHSA-m4vx-w6j3-jp82.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Unify unpack_streams check
Tobias Stoeckmann [Thu, 25 Jun 2026 18:06:30 +0000 (20:06 +0200)] 
7zip: Unify unpack_streams check

Use checked arithmetic and unify unpack_streams check to cover all
cases. This should be a purely defensive measure.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Unify UMAX_ENTRY check
Tobias Stoeckmann [Thu, 25 Jun 2026 17:40:27 +0000 (19:40 +0200)] 
7zip: Unify UMAX_ENTRY check

Introduce parse_7zip_size, which performs the UMAX_ENTRY check.
Generally, use this function whenever memory allocation sizes or indices
into memory allocations are used, i.e. when size_t is meant.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Use checked arithmetic more often
Tobias Stoeckmann [Thu, 25 Jun 2026 17:17:36 +0000 (19:17 +0200)] 
7zip: Use checked arithmetic more often

Use checked arithmetic to avoid overflows. Use it also where checks are
already in place for better readability.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Simplify decode_codec_id
Tobias Stoeckmann [Thu, 25 Jun 2026 17:04:59 +0000 (19:04 +0200)] 
7zip: Simplify decode_codec_id

Since we have checked integer arithmetic now, use it.
Clarify that INT64_MAX is the maximum according to standard.

With that, switch to int64_t to avoid (unsigned long)-1 casts.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Check numDigests in read_SubStreamsInfo
Tobias Stoeckmann [Thu, 25 Jun 2026 16:54:47 +0000 (18:54 +0200)] 
7zip: Check numDigests in read_SubStreamsInfo

Verify that sum of numUnpackStreams will never overflow numDigests. For
this, also set numDigests to size_t because that's how the variable is
used later on.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Handle large requests in extract_pack_stream
Tobias Stoeckmann [Thu, 25 Jun 2026 16:30:15 +0000 (18:30 +0200)] 
7zip: Handle large requests in extract_pack_stream

If the minimum amount of bytes could overflow size_t after alignment,
allocate exact minimum amount instead.

This avoids integer overflow and will most likely lead to regular OOM
error handling instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days ago7zip: Skip bytes in read_stream in chunks
Tobias Stoeckmann [Thu, 25 Jun 2026 16:08:59 +0000 (18:08 +0200)] 
7zip: Skip bytes in read_stream in chunks

Avoid huge requests while skipping bytes to avoid integer truncation and
memory allocation issues.

3 days ago7zip: Improve integer handling in skip_stream
Tobias Stoeckmann [Thu, 25 Jun 2026 15:34:09 +0000 (17:34 +0200)] 
7zip: Improve integer handling in skip_stream

The skip_stream function is supposed to skip a specified amount of bytes
from input stream. Since streams could be larger than 4 GB even on 32
bit systems, do not cast to size_t. Instead, read the data in small
chunks until all bytes are skipped.

This also helps to avoid large allocations on 64 bit systems.

Also verify that skipped_bytes tracking cannot overflow.

While at it, change return value to int because it's only needed for
status information, i.e. if operation was successful or not. This avoids
another cast issue with uint64_t values larger than INT64_MAX.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 days agoMerge pull request #3181 from uchiha-bug-hunter/xar-atou64-overread
Dustin L. Howett [Fri, 26 Jun 2026 12:56:20 +0000 (07:56 -0500)] 
Merge pull request #3181 from uchiha-bug-hunter/xar-atou64-overread

3 days agoxar: stop atou64 reading one byte past the numeric field 3181/head
Kaif Khan [Thu, 25 Jun 2026 09:04:42 +0000 (14:34 +0530)] 
xar: stop atou64 reading one byte past the numeric field

3 days agoxar: add regression test for atou64 numeric field over-read
Kaif Khan [Fri, 26 Jun 2026 08:27:11 +0000 (13:57 +0530)] 
xar: add regression test for atou64 numeric field over-read

Exercise atou64() through a TOC numeric element (<inode>) read via the
expat backend, which hands the parser its raw, non-NUL-terminated
character-data buffer. Mirrors test_read_format_xar_base64_oob; build
with ASan for the out-of-bounds coverage.

4 days agoMerge pull request #3183 from uchiha-bug-hunter/gnutar-gname-overflow
Dustin L. Howett [Thu, 25 Jun 2026 23:31:30 +0000 (18:31 -0500)] 
Merge pull request #3183 from uchiha-bug-hunter/gnutar-gname-overflow

4 days agoMerge pull request #3182 from bluca/seek_issue
Dustin L. Howett [Thu, 25 Jun 2026 19:01:53 +0000 (14:01 -0500)] 
Merge pull request #3182 from bluca/seek_issue

read_data_into_fd: Fix spurious "Seek error" for trailing holes

4 days agoread_data_into_fd: Fix spurious "Seek error" for trailing holes 3182/head
Luca Boccassi [Thu, 25 Jun 2026 15:53:19 +0000 (16:53 +0100)] 
read_data_into_fd: Fix spurious "Seek error" for trailing holes

The final seek check never advanced actual_offset for the trailing
hole created by the EOF pad_to(), so extracting any sparse file whose
last region is a hole failed with ARCHIVE_FATAL "Seek error".

This affects the systemd CI which does such an operation, and now
fails since PR https://github.com/libarchive/libarchive/pull/3128
was merged and appeared in Archlinux:

 [  269.636946] TEST-13-NSPAWN.sh[5439]: + run0 --pipe -u testuser importctl -m --user import-tar - inodetest2
 [  270.132545] TEST-13-NSPAWN.sh[5440]: Enqueued transfer job 7. Press C-c to continue download in background.
 [  270.137660] TEST-13-NSPAWN.sh[5440]: Exporting '/home/testuser/.local/state/machines/inodetest', saving to 'pipe:[79515]' with compression 'uncompressed'.
 [  270.148434] TEST-13-NSPAWN.sh[5441]: Enqueued transfer job 8. Press C-c to continue download in background.
 [  270.173410] TEST-13-NSPAWN.sh[5441]: Importing 'pipe:[79515]', saving as 'inodetest2'.
 [  270.178790] TEST-13-NSPAWN.sh[5441]: Operating on image directory '/home/testuser/.local/state/machines'.
 [  270.386155] TEST-13-NSPAWN.sh[5440]: Operation completed successfully.
 [  270.389171] TEST-13-NSPAWN.sh[5440]: Exiting.
 [  270.689994] TEST-13-NSPAWN.sh[5441]: Failed to unpack regular file 'testfile': Seek error

https://github.com/systemd/systemd/actions/runs/28159904022/job/83436896561?pr=42736

A local and small regression test is added that replicates that test's
behaviour.

4 days agognutar: fix stack overflow writing oversized gname field 3183/head
Kaif Khan [Thu, 25 Jun 2026 16:52:56 +0000 (22:22 +0530)] 
gnutar: fix stack overflow writing oversized gname field

4 days agognutar: add regression test for oversized gname field
Kaif Khan [Thu, 25 Jun 2026 16:52:56 +0000 (22:22 +0530)] 
gnutar: add regression test for oversized gname field

5 days agoMerge pull request #3180 from dag-erling/des/3.8.8-fixes
Dustin L. Howett [Wed, 24 Jun 2026 18:51:42 +0000 (13:51 -0500)] 
Merge pull request #3180 from dag-erling/des/3.8.8-fixes

Miscellaneous fixes for 3.8.8

* configure.ac: Remove unused checks
* libarchive: Fix `TIME_MAX` and `TIME_MIN`
* test: Fix off-by-one in bounds check
Fixes: 0e4fa9ff0d82 ("test: promote the win32-repairing systemf wrapper to all systemf calls")
* bsdunzip_test: Set umask before asserting permissions
Fixes: 34b3da0013ae ("unzip: Add symlink tests")
* archive_write_disk_posix: Fix type issues
  Fix type issues in the HFS+ (de)compression code, primarily to avoid
  arithmetic overflow when calculating the block count during compression.
* archive_write_disk_posix: Miscellaneous cleanup
  Use `S_IS*()` macros consistently and clean up some `#ifdef`s.
* archive_write_disk_posix: Symlinks can have AppleDouble data
* libarchive: Fix format string issues

5 days agoMerge pull request #3177 from DHowett/zisofs-creation-size
Dustin L. Howett [Wed, 24 Jun 2026 18:13:40 +0000 (13:13 -0500)] 
Merge pull request #3177 from DHowett/zisofs-creation-size

5 days agolibarchive: Fix format string issues 3180/head
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:58:29 +0000 (17:58 +0200)] 
libarchive: Fix format string issues

5 days agoarchive_write_disk_posix: Symlinks can have AppleDouble data
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:55:41 +0000 (17:55 +0200)] 
archive_write_disk_posix: Symlinks can have AppleDouble data

5 days agoarchive_write_disk_posix: Miscellaneous cleanup
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:54:10 +0000 (17:54 +0200)] 
archive_write_disk_posix: Miscellaneous cleanup

Use S_IS*() macros consistently and clean up some #ifdefs.

5 days agoarchive_write_disk_posix: Fix type issues
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:51:44 +0000 (17:51 +0200)] 
archive_write_disk_posix: Fix type issues

Fix type issues in the HFS+ (de)compression code, primarily to avoid
arithmetic overflow when calculating the block count during compression.

5 days agobsdunzip_test: Set umask before asserting permissions
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:49:26 +0000 (17:49 +0200)] 
bsdunzip_test: Set umask before asserting permissions

Fixes: 34b3da0013ae ("unzip: Add symlink tests")

5 days agotest: Fix off-by-one in bounds check
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:48:45 +0000 (17:48 +0200)] 
test: Fix off-by-one in bounds check

Fixes: 0e4fa9ff0d82 ("test: promote the win32-repairing systemf wrapper to all systemf calls")

5 days agolibarchive: Fix TIME_MAX and TIME_MIN
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:47:08 +0000 (17:47 +0200)] 
libarchive: Fix TIME_MAX and TIME_MIN

5 days agounzip: mark bsdunzip as long-path aware on Windows 3167/head
Reyad Attiyat [Tue, 23 Jun 2026 20:38:11 +0000 (15:38 -0500)] 
unzip: mark bsdunzip as long-path aware on Windows

Signed-off-by: God-damnit-all <53661808+God-damnit-all@users.noreply.github.com>
5 days agounzip: Add Windows port
Tobias Stoeckmann [Sun, 21 Jun 2026 13:31:43 +0000 (15:31 +0200)] 
unzip: Add Windows port

Copy missing functionality from libarchive and cpio.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 days agoiso9660: do not overflow zisofs block pointer count when a file is ~4GiB 3177/head
Dustin L. Howett [Tue, 23 Jun 2026 22:56:01 +0000 (17:56 -0500)] 
iso9660: do not overflow zisofs block pointer count when a file is ~4GiB

(applies to 32-bit builds of libarchive)

Files within one ZF_BLOCK_SIZE of 4 GiB (which is, incidentally, the max
zisofs-compressible file size) would trigger an overflow in the
calculation of the number of block _pointers_ they would require. We
could have rejected those files, but the truth is that they just require
exactly 131073 block pointers (131072 for the file itself and one for
the trailer.)

5 days agoiso9660: add a test for the 32-bit zisofs overflow case
Dustin L. Howett [Wed, 24 Jun 2026 14:30:41 +0000 (09:30 -0500)] 
iso9660: add a test for the 32-bit zisofs overflow case

Writing a file near 4 GiB causes an overflow when we calculate the
number of block pointers we need to store, which leads to us allocating
the wrong amount of memory to store them.

This is visible with ASan:

Exercising: libarchive 3.9.0dev zlib/1.3.1 liblzma/5.4.4 bz2lib/1.0.8 libzstd/1.5.6 cng/2.0 libb2/bundled
706: test_write_format_iso9660_zisofs_overflow
=================================================================
==40444==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x08c004b4 at pc 0x006acb3b bp 0x002edb44 sp 0x002edb38
WRITE of size 1 at 0x08c004b4 thread T0
    #0 0x006acb3a in archive_le32enc libarchive\archive_endian.h:219
    #1 0x006c81d0 in zisofs_write_to_temp libarchive\archive_write_set_format_iso9660.c:7760
    #2 0x006ca1bd in write_iso9660_data libarchive\archive_write_set_format_iso9660.c:1785

5 days agounzip: Improve portability
Tobias Stoeckmann [Sun, 21 Jun 2026 13:30:43 +0000 (15:30 +0200)] 
unzip: Improve portability

- Use contrib/untar's system_mkdir for extended portability
- Compile warning function only if it's actually used
- Use %H:%M instead of %R in strftime for extended portability
- Introduce system_unlink to add special directory symlink handling

Copy missing functionality from libarchive and cpio.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 days agoconfigure.ac: Remove unused checks
Dag-Erling Smørgrav [Wed, 24 Jun 2026 15:41:19 +0000 (17:41 +0200)] 
configure.ac: Remove unused checks

5 days agoMerge pull request #3160 from GeorgH93/fix_zipx_streaming_non_seekable
Dustin L. Howett [Wed, 24 Jun 2026 13:42:37 +0000 (08:42 -0500)] 
Merge pull request #3160 from GeorgH93/fix_zipx_streaming_non_seekable

Fix zipx reading with ZIP_LENGTH_AT_END flag from non-seekable source

5 days agoMerge pull request #3175 from uchiha-bug-hunter/xar-base64-oob-read
Tim Kientzle [Wed, 24 Jun 2026 13:10:15 +0000 (06:10 -0700)] 
Merge pull request #3175 from uchiha-bug-hunter/xar-base64-oob-read

xar: fix OOB read decoding odd-length base64 in strappend_base64

5 days agoMerge pull request #3178 from uchiha-bug-hunter/unzip-pathname-dotdot
Tim Kientzle [Wed, 24 Jun 2026 13:08:25 +0000 (06:08 -0700)] 
Merge pull request #3178 from uchiha-bug-hunter/unzip-pathname-dotdot

unzip: reject bare '..' and trailing '/..' in pathname_is_insecure

5 days agounzip: reject bare '..' and trailing '/..' in pathname_is_insecure 3178/head
Kaif Khan [Wed, 24 Jun 2026 06:30:05 +0000 (12:00 +0530)] 
unzip: reject bare '..' and trailing '/..' in pathname_is_insecure

5 days agounzip: add regression test for insecure '..' symlink targets
Kaif Khan [Wed, 24 Jun 2026 06:30:05 +0000 (12:00 +0530)] 
unzip: add regression test for insecure '..' symlink targets

5 days agoxar: fix OOB read decoding odd-length base64 in strappend_base64 3175/head
Kaif Khan [Tue, 23 Jun 2026 17:46:44 +0000 (23:16 +0530)] 
xar: fix OOB read decoding odd-length base64 in strappend_base64

5 days agoxar: add regression test for odd-length base64 name decoding
Kaif Khan [Tue, 23 Jun 2026 17:46:44 +0000 (23:16 +0530)] 
xar: add regression test for odd-length base64 name decoding

Crafted TOC with a base64-encoded <name> of odd length, which used to
make strappend_base64() read past the character-data buffer. The trailing
incomplete base64 character is dropped; the rest still decodes.

5 days agoMerge pull request #3162 from soda0289/add-windows-long-path-manifest
Dustin L. Howett [Wed, 24 Jun 2026 04:33:12 +0000 (23:33 -0500)] 
Merge pull request #3162 from soda0289/add-windows-long-path-manifest

tar: mark bsdtar as long-path aware on Windows

tar -C/--directory option calls SetCurrentDirectoryW(), which is limited to MAX_PATH (260) characters unless the process opts in to longpath support via an application manifest and enables a registry setting or sets an option in developer settings.

6 days agoMerge pull request #3176 from stoeckmann/unzip_tests
Tobias Stoeckmann [Tue, 23 Jun 2026 18:29:22 +0000 (20:29 +0200)] 
Merge pull request #3176 from stoeckmann/unzip_tests

unzip: Extend test suite

6 days agounzip: Add symlink tests 3176/head
Tobias Stoeckmann [Mon, 22 Jun 2026 20:29:11 +0000 (22:29 +0200)] 
unzip: Add symlink tests

Verify that symlink creations and overwriting works, i.e. that dangling
symlinks are properly overwritten.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agounzip: Add -u test
Tobias Stoeckmann [Mon, 22 Jun 2026 19:50:47 +0000 (21:50 +0200)] 
unzip: Add -u test

Verify that -u does not override files which have a newer timestamp.

This also verifies that creation of timestamps properly works.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>