]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
3 weeks agocab: Extend Huffman documentation 3246/head
Tobias Stoeckmann [Sun, 5 Jul 2026 17:22:00 +0000 (19:22 +0200)] 
cab: Extend Huffman documentation

Explain the algorithm and data structure involved in Huffman tree
handling as array. Hopefully simplifies upcoming code change
verifications.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago[Read core] Allow format readers to FAIL a header read 3245/head
Tim Kientzle [Sun, 5 Jul 2026 17:12:33 +0000 (10:12 -0700)] 
[Read core] Allow format readers to FAIL a header read

While investigating improvements to Zip's header reading,
I found an overlooked case in the read core:  When a format
returned FAILED for a header read (indicating that the entry
could not be read but that the archive as a whole is still valid),
the core silently converted that to FATAL, ending the archive
at that point.

The change to the read core adds a new internal state "DATA_RECOVERY"
indicating that we're post-header (like the existing DATA state) but
that client requests to actually obtain data are not valid.

3 weeks ago[Read core] Test handling of FAILED header reads
Tim Kientzle [Sun, 5 Jul 2026 17:11:50 +0000 (10:11 -0700)] 
[Read core] Test handling of FAILED header reads

While investigating improvements to Zip's header reading,
I found an overlooked case in the read core:  When a format
returned FAILED for a header read (indicating that the entry
could not be read but that the archive as a whole is still valid),
the core silently converted that to FATAL, ending the archive
at that point.

Two formats already returned FAILED for certain header issues:
Zip and LHA both indicated unreadable symlink entries in this way,
which should allow the rest of the archive to continue being read.
New tests here verify that we can now continue reading past
such entries, and that clients who ignore the FAILED result
get the same FATAL handling as other API misuse.

3 weeks agowarc: track remaining entry bytes when writing data 3244/head
data [Sun, 5 Jul 2026 16:31:53 +0000 (00:31 +0800)] 
warc: track remaining entry bytes when writing data

The WARC writer capped each data write against the full declared entry
size, but never reduced that value after accepting data. As a result,
repeated write calls could emit more bytes than the WARC Content-Length.

Track the remaining byte count for the current regular-file entry and
decrement it after each successful write. Further writes are then
clamped to the remaining length and return zero once the entry is full.

3 weeks agowarc: test repeated writes past Content-Length
data [Sun, 5 Jul 2026 16:28:38 +0000 (00:28 +0800)] 
warc: test repeated writes past Content-Length

Verify that a WARC entry does not accept bytes after its declared
Content-Length has already been written.

3 weeks agoMerge pull request #3242 from datauwu/zip-basic-support-0x000d
Tim Kientzle [Sun, 5 Jul 2026 15:38:11 +0000 (08:38 -0700)] 
Merge pull request #3242 from datauwu/zip-basic-support-0x000d

zip: read PKWARE Unix extra field metadata

3 weeks agocab: Do not nest struct definitions
Tobias Stoeckmann [Sun, 5 Jul 2026 15:27:14 +0000 (17:27 +0200)] 
cab: Do not nest struct definitions

This complies with other C source files of format parsers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoacl: fix over-read on empty field in archive_acl_from_text_nl 3236/head
Kaif Khan [Sun, 5 Jul 2026 08:09:58 +0000 (13:39 +0530)] 
acl: fix over-read on empty field in archive_acl_from_text_nl

archive_acl_from_text_nl() parses ACL text from a pointer and a length
and does not require a NUL terminator; the tar reader passes a
__archive_read_ahead() window of exactly value_length bytes for
SCHILY.acl.access/.default/.ace.  When an entry is empty (a
whitespace-only value, or trailing whitespace after a valid entry)
next_field() consumes the rest of the buffer as whitespace and leaves
field[0].start one past the end, which the '#'-comment probe then
dereferences.  Capture the buffer end and skip the entry when its first
field starts there.  The wide archive_acl_from_text_w is NUL terminated
and unaffected.

3 weeks agoacl: add test_acl_from_text_overread regression test
Kaif Khan [Sun, 5 Jul 2026 08:09:52 +0000 (13:39 +0530)] 
acl: add test_acl_from_text_overread regression test

Drives archive_acl_from_text_nl() with exact-length, non-NUL-terminated
buffers whose first field is only whitespace, covering the empty-entry
and trailing-whitespace cases.  Allow the test to include
archive_acl_private.h via __LIBARCHIVE_TEST.

3 weeks agozip: read PKWARE Unix extra field metadata 3242/head
datauwu [Sun, 5 Jul 2026 05:22:03 +0000 (13:22 +0800)] 
zip: read PKWARE Unix extra field metadata

Read the fixed metadata prefix of the PKWARE Unix extra field 0x000d.

The fixed portion contains atime, mtime, uid, and gid values. Require
the full 12-byte prefix before reading it, and leave the variable-length
data field unsupported for now.

3 weeks agozip: test PKWARE Unix extra field
datauwu [Sun, 5 Jul 2026 05:22:03 +0000 (13:22 +0800)] 
zip: test PKWARE Unix extra field

Add a test for the PKWARE Unix extra field 0x000d.

The fixture stores a regular file with the 12-byte fixed metadata
prefix in both the local header and central directory. The test checks
that the ZIP reader exposes mtime, atime, uid, and gid metadata for
seekable and streaming reads.

3 weeks agoMerge pull request #3240 from kientzle/kientzle-zip-uncompressed-size-exact-check
Tim Kientzle [Sun, 5 Jul 2026 05:06:35 +0000 (22:06 -0700)] 
Merge pull request #3240 from kientzle/kientzle-zip-uncompressed-size-exact-check

[Zip] Reject archives if the 32-bit size field is not correct

3 weeks agoMerge pull request #3232 from kientzle/kientzle-read-data-into-fd-size-boundary
Dustin L. Howett [Sat, 4 Jul 2026 20:08:23 +0000 (15:08 -0500)] 
Merge pull request #3232 from kientzle/kientzle-read-data-into-fd-size-boundary

[Write] Truncate write-to-fd at the declared entry size

3 weeks agoMerge pull request #3219 from DHowett/custom-clang-in-ci
Dustin L. Howett [Sat, 4 Jul 2026 19:57:14 +0000 (14:57 -0500)] 
Merge pull request #3219 from DHowett/custom-clang-in-ci

ci: add a new Lint step that uses a custom-built linter

3 weeks agoMerge pull request #3237 from datauwu/tar-avoid-redundant-mode
Dustin L. Howett [Sat, 4 Jul 2026 19:56:02 +0000 (14:56 -0500)] 
Merge pull request #3237 from datauwu/tar-avoid-redundant-mode

 tar: avoid redundant mode parsing

3 weeks agoMerge pull request #3233 from stoeckmann/archive_entry_new2
Dustin L. Howett [Sat, 4 Jul 2026 19:51:49 +0000 (14:51 -0500)] 
Merge pull request #3233 from stoeckmann/archive_entry_new2

Check `archive_entry_new2` return value

3 weeks agoMerge pull request #3234 from stoeckmann/raw_oflow
Dustin L. Howett [Sat, 4 Jul 2026 19:51:31 +0000 (14:51 -0500)] 
Merge pull request #3234 from stoeckmann/raw_oflow

raw: Properly treat huge inputs

3 weeks agolint: compile la-lint and use in place of clang-tidy 3219/head
Dustin L. Howett [Wed, 1 Jul 2026 15:05:37 +0000 (10:05 -0500)] 
lint: compile la-lint and use in place of clang-tidy

3 weeks agoMerge commit '25ef914386252adbf67d07d6c5bf018dfcbe34a9' as 'build/la-lint'
Dustin L. Howett [Sat, 4 Jul 2026 19:42:27 +0000 (14:42 -0500)] 
Merge commit '25ef914386252adbf67d07d6c5bf018dfcbe34a9' as 'build/la-lint'

3 weeks agoSquashed 'build/la-lint/' content from commit 66dbe023
Dustin L. Howett [Sat, 4 Jul 2026 19:42:27 +0000 (14:42 -0500)] 
Squashed 'build/la-lint/' content from commit 66dbe023

git-subtree-dir: build/la-lint
git-subtree-split: 66dbe023892df333ae794f6004553ff0a3d32275

3 weeks agobuild: add a new "lint" workflow that runs clang-tidy
Dustin L. Howett [Tue, 30 Jun 2026 14:48:44 +0000 (09:48 -0500)] 
build: add a new "lint" workflow that runs clang-tidy

3 weeks agobuild: add ENABLE_CLANG_TIDY and CLANG_TIDY_PATH
Dustin L. Howett [Tue, 30 Jun 2026 14:43:53 +0000 (09:43 -0500)] 
build: add ENABLE_CLANG_TIDY and CLANG_TIDY_PATH

3 weeks agoMerge pull request #3239 from datauwu/warc-require-size
Dustin L. Howett [Sat, 4 Jul 2026 19:24:22 +0000 (14:24 -0500)] 
Merge pull request #3239 from datauwu/warc-require-size

3 weeks agowarc: require file size before writing header 3239/head
datauwu [Sat, 4 Jul 2026 17:26:57 +0000 (01:26 +0800)] 
warc: require file size before writing header

WARC records require a known Content-Length. Reject regular file
entries without a valid size instead of treating them as zero.
Avoid casting archive_entry_size() through size_t before storing it in
the uint64_t WARC Content-Length field, since that can truncate large
sizes on 32-bit platforms.

3 weeks agoMerge pull request #3238 from stoeckmann/cpio_ioflow
Tim Kientzle [Sat, 4 Jul 2026 17:43:37 +0000 (10:43 -0700)] 
Merge pull request #3238 from stoeckmann/cpio_ioflow

cpio: Prevent signed integer overflow

3 weeks agowarc: test missing file size handling
datauwu [Sat, 4 Jul 2026 17:26:57 +0000 (01:26 +0800)] 
warc: test missing file size handling

Add coverage for WARC entries without a known size. The writer
must reject these entries because WARC requires Content-Length.

3 weeks agocpio: Prevent signed integer overflow 3238/head
Tobias Stoeckmann [Sat, 4 Jul 2026 17:06:52 +0000 (19:06 +0200)] 
cpio: Prevent signed integer overflow

If enough bytes have to be skipped, a signed integer overflow could
occur (most realistically on 32 bit systems). Use an unsigned type,
which could still overflow but has only negative impact on diagnostic
warning message.

Follow up of 02fa05675fdf8054ae0dd73df8c5264e61f3a068 but this time for
function find_newc_header.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoUpdate libarchive/archive_read_data_into_fd.c 3232/head
Tim Kientzle [Sat, 4 Jul 2026 16:48:31 +0000 (09:48 -0700)] 
Update libarchive/archive_read_data_into_fd.c

Co-authored-by: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>
3 weeks agoMerge pull request #3231 from datauwu/7zip-skip-archiveproperties
Tobias Stoeckmann [Sat, 4 Jul 2026 07:56:23 +0000 (09:56 +0200)] 
Merge pull request #3231 from datauwu/7zip-skip-archiveproperties

7zip: skip ArchiveProperties payload data

3 weeks agopax: remove redundant hardlink size assignment 3237/head
datauwu [Sat, 4 Jul 2026 05:57:33 +0000 (13:57 +0800)] 
pax: remove redundant hardlink size assignment

archive_write_pax_header() set hardlink entries to size zero for the
restricted pax format, then immediately set all hardlink entries to size
zero again.

Remove the narrower check because it is fully subsumed by the following
hardlink check.

No functional change intended.

3 weeks agotar: avoid parsing mode field twice
datauwu [Sat, 4 Jul 2026 05:57:32 +0000 (13:57 +0800)] 
tar: avoid parsing mode field twice

header_common() parsed the tar mode field once when setting the file
type and again when setting permissions. Cache the parsed value and reuse
it for both setters.

archive_entry_set_filetype() and archive_entry_set_perm() already mask
the relevant bits, so passing the full header mode preserves behavior.
The permission-set guard is unchanged.

No functional change intended.

3 weeks agoFix the test failure
Tim Kientzle [Sat, 4 Jul 2026 04:52:27 +0000 (21:52 -0700)] 
Fix the test failure

This was originally developed without the Zip fix from #3230.
Since that's been merged, we need to adjust the expectations here
a bit.

3 weeks agoRework size-overrun check to avoid arithmetic errors
Tim Kientzle [Fri, 3 Jul 2026 23:09:16 +0000 (16:09 -0700)] 
Rework size-overrun check to avoid arithmetic errors

3 weeks ago[Write] Truncate write-to-fd at the declared entry size
Tim Kientzle [Fri, 3 Jul 2026 20:05:41 +0000 (13:05 -0700)] 
[Write] Truncate write-to-fd at the declared entry size

This is the fix for....

Update the common archive_read_data_into_fd() to truncate
output to the actual entry size from the most recent
archive_read_header result.

This addresses a hole in handling of certain subtly-malformed archives
that can have more data than declared in the header.  Before this,
bsdtar explicitly truncates the entry data to the actual declared size
when extracting to a file, but did not do so when extracting to
stdout.

3 weeks ago[Write] Truncate write-to-fd at the declared entry size
Tim Kientzle [Fri, 3 Jul 2026 19:57:07 +0000 (12:57 -0700)] 
[Write] Truncate write-to-fd at the declared entry size

This is the test for....

Update the common archive_read_data_into_fd() to truncate
output to the actual entry size from the most recent
archive_read_header result.

This addresses a hole in handling of certain subtly-malformed archives
that can have more data than declared in the header.  Before this,
bsdtar explicitly truncates the entry data to the actual declared size
when extracting to a file, but did not do so when extracting to
stdout.

3 weeks ago[Zip] Reject archives if the 32-bit size field is not correct 3240/head
Tim Kientzle [Sat, 4 Jul 2026 04:25:54 +0000 (21:25 -0700)] 
[Zip] Reject archives if the 32-bit size field is not correct

Reverse an old experiment: When the 32-bit size field is provided, it
now must match the actual size exactly.  We no longer permit it to
only match the least-significant 32 bits of the actual size.

--begin-history--
When developing the earliest versions of libarchive's Zip support, I
experimented with the idea of supporting greater-than-4GiB entries in
32-bit Zip archives.  This proved to be technically feasible as long
as the _compressed_ data was small enough to keep the resulting
archive under 4GiB.  But this also required us to interpret
the 32-bit uncompressed size field as representing only the
least-significant 32 bits of the size.
--end-history--

3 weeks ago[Zip] Be strict about the 32-bit uncompressed size
Tim Kientzle [Sat, 4 Jul 2026 04:22:48 +0000 (21:22 -0700)] 
[Zip] Be strict about the 32-bit uncompressed size

Test:  If the uncompressed size stored in the archive differs
from the actual uncompressed size by a multiple of 2^32,
we should report some kind of error.

This currently goes undiagnosed because of an old attempt
to support larger-than-4GiB entries in plain 32-bit Zip
archives without necessarily requiring Zip64 extensions.
While this is technically feasible, it requires treating
the 32-bit size field ambiguously, which can lead to size
confusion from readers.

3 weeks ago7zip: skip ArchiveProperties payload data 3231/head
datauwu [Fri, 3 Jul 2026 17:21:34 +0000 (01:21 +0800)] 
7zip: skip ArchiveProperties payload data

ArchiveProperties entries have a property ID, a size, and payload.

The reader parsed the ID and size, but did not consume the payload.
Payload bytes could then be read as the next property ID, which
misaligned the rest of header parsing.

Skip the payload in chunks so parsing stays aligned with 7-Zip/7zz.

3 weeks agoraw: Properly treat huge inputs 3234/head
Tobias Stoeckmann [Fri, 3 Jul 2026 21:15:03 +0000 (23:15 +0200)] 
raw: Properly treat huge inputs

If the raw parser ever treats a basically endless stream which
eventually overflows INT64_MAX, fail instead of overflowing
offset + size calculation, leading to subsequent issues in callers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoCheck archive_entry_new2 return value 3233/head
Tobias Stoeckmann [Fri, 3 Jul 2026 20:45:11 +0000 (22:45 +0200)] 
Check archive_entry_new2 return value

The memory allocation might fail. Check return value and properly handle
error cases.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #3230 from kientzle/kientzle-zip-reject-overlong-bodies
Tim Kientzle [Fri, 3 Jul 2026 20:26:30 +0000 (13:26 -0700)] 
Merge pull request #3230 from kientzle/kientzle-zip-reject-overlong-bodies

[Zip] Reject entries with overlong bodies

3 weeks ago[Zip] Reject entries with overlong bodies 3230/head
Tim Kientzle [Fri, 3 Jul 2026 20:14:27 +0000 (13:14 -0700)] 
[Zip] Reject entries with overlong bodies

If an entry declares an uncompressed size, we should not return any
data beyond that point.  This doesn't impact bsdtar and friends since
they independently truncate to the declared entry size, but other
clients may not be so careful.

Apparently discovered (but not reported) by @bikini
Reported by @dkgkdfg65

3 weeks ago[Zip] Reject entries with overlong bodies
Tim Kientzle [Fri, 3 Jul 2026 20:13:31 +0000 (13:13 -0700)] 
[Zip] Reject entries with overlong bodies

Tests for...

If an entry declares an uncompressed size, we should not return any
data beyond that point.  This doesn't impact bsdtar and friends since
they independently truncate to the declared entry size, but other
clients may not be so careful.

Apparently discovered (but not reported) by @bikini
Reported by @dkgkdfg65

3 weeks agoMerge pull request #3229 from stoeckmann/cab_e8
Dustin L. Howett [Fri, 3 Jul 2026 18:38:20 +0000 (13:38 -0500)] 
Merge pull request #3229 from stoeckmann/cab_e8

3 weeks ago7zip: add ArchiveProperties payload test
datauwu [Fri, 3 Jul 2026 17:16:18 +0000 (01:16 +0800)] 
7zip: add ArchiveProperties payload test

Add a 7z test archive with a non-empty ArchiveProperties payload.

The archive has one empty file and an ArchiveProperties entry with a
1-byte payload. It is accepted by 7-Zip/7zz.

This covers parsing when ArchiveProperties has payload bytes.

3 weeks agoMerge pull request #3228 from datauwu/zip-encrypted-int-overflow
Tim Kientzle [Fri, 3 Jul 2026 16:36:45 +0000 (09:36 -0700)] 
Merge pull request #3228 from datauwu/zip-encrypted-int-overflow

zip: avoid signed overflow in encrypted size checks

3 weeks agozip: avoid signed overflow in encrypted size checks 3228/head
datauwu [Fri, 3 Jul 2026 09:36:50 +0000 (17:36 +0800)] 
zip: avoid signed overflow in encrypted size checks

Avoid adding the encryption overhead directly to entry sizes when deciding
whether Zip64 is needed or when updating the stored compressed size.

For the Zip64 decision, compare against ZIP_4GB_MAX - additional_size. For
stored encrypted entries, use archive_ckd_add_i64() so the size update and
overflow check happen together.

3 weeks agocab: Add E8 translation test 3229/head
Tobias Stoeckmann [Fri, 3 Jul 2026 15:19:01 +0000 (17:19 +0200)] 
cab: Add E8 translation test

Covers basic E8 translations, yet it lacks the handling of negative
values because this would require large archives.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocab: Translate E8 calls only in first 1 GB of data
Tobias Stoeckmann [Fri, 3 Jul 2026 15:10:11 +0000 (17:10 +0200)] 
cab: Translate E8 calls only in first 1 GB of data

The cab specification states that E8 translation shall be performed only
within the first 1 GB range of an uncompressed file, i.e. for the first
0x8000 CFDATA entries in a folder.

Take this limit properly into account.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #3208 from datauwu/7zip-skip-defined-bitmaps
Dustin L. Howett [Fri, 3 Jul 2026 01:22:52 +0000 (20:22 -0500)] 
Merge pull request #3208 from datauwu/7zip-skip-defined-bitmaps

3 weeks ago7zip: skip fully-defined metadata bitmaps 3208/head
datauwu [Fri, 3 Jul 2026 00:14:11 +0000 (08:14 +0800)] 
7zip: skip fully-defined metadata bitmaps

Avoid allocating and filling metadata bitmaps when the 7z header says
that every file has the corresponding value.

Sparse metadata still uses the existing bitmap path.

3 weeks agoMerge pull request #3224 from datauwu/formats-remove-unused-state
Dustin L. Howett [Thu, 2 Jul 2026 22:27:28 +0000 (17:27 -0500)] 
Merge pull request #3224 from datauwu/formats-remove-unused-state

formats: remove unused states from 7 formats

3 weeks agoMerge pull request #3226 from uchiha-bug-hunter/pathmatch-wide-bracket-overread
Dustin L. Howett [Thu, 2 Jul 2026 19:40:59 +0000 (14:40 -0500)] 
Merge pull request #3226 from uchiha-bug-hunter/pathmatch-wide-bracket-overread

pathmatch: fix wide-char bracket over-read in pm_w

3 weeks agowin32: repair symlink mode 'H' (hybrid) in wildcard search 3227/head
Dustin L. Howett [Thu, 2 Jul 2026 15:31:37 +0000 (10:31 -0500)] 
win32: repair symlink mode 'H' (hybrid) in wildcard search

The Windows disk reader supports wildcards by converting a path like
"foo/*" into a single tree rooted at "foo/". This does not play nicely
with symlink mode `H`, which treats the first item in each tree as a
dereferenced link (L) and all subsequent items as physical links (P). On
Windows, we take the first _match_ in L mode and all subsequent
descendants and matches in P mode.

This creates a behavioral difference between `bsdtar -c -H *` and
`bsdtar -c -H one two three`.

This commit changes how we handle H->L/P transitions when doing wildcard
matches. The transition from H to P is now done when we descend into our
first directory, and we switch back to H mode when we ascend out of
it[^1].

Closes #3222

[^1]: This does not matter in practice because tree is breadth-first
rather than depth-first, but I've done it in the interest of
completeness and not leaving ourselves caltrops to step on later.

3 weeks agopathmatch: guard end-of-string before wide bracket class match 3226/head
Kaif Khan [Thu, 2 Jul 2026 17:06:44 +0000 (22:36 +0530)] 
pathmatch: guard end-of-string before wide bracket class match

3 weeks agotest: cover wide bracket over-read in pm_w
Kaif Khan [Thu, 2 Jul 2026 17:06:44 +0000 (22:36 +0530)] 
test: cover wide bracket over-read in pm_w

3 weeks agowrite: remove unused zip and warc fields 3224/head
datauwu [Thu, 2 Jul 2026 13:44:48 +0000 (21:44 +0800)] 
write: remove unused zip and warc fields

Remove writer fields that are initialized but never read.

3 weeks agorar5: remove unused filter_info fields
datauwu [Thu, 2 Jul 2026 13:44:48 +0000 (21:44 +0800)] 
rar5: remove unused filter_info fields

Remove filter_info fields that are never assigned or read.

3 weeks agorar: remove unused globalbackup fields
datauwu [Thu, 2 Jul 2026 13:44:48 +0000 (21:44 +0800)] 
rar: remove unused globalbackup fields

Remove RAR filter backup fields that are never used.

3 weeks agocab: remove unused LZX tree_used state
datauwu [Thu, 2 Jul 2026 13:44:48 +0000 (21:44 +0800)] 
cab: remove unused LZX tree_used state

Remove LZX Huffman state that is reset but never read.

3 weeks agocab: remove unused header and entry fields
datauwu [Thu, 2 Jul 2026 13:44:48 +0000 (21:44 +0800)] 
cab: remove unused header and entry fields

Remove CAB fields that are parsed or reset but never read.

3 weeks agozip: remove unused central directory counters
datauwu [Thu, 2 Jul 2026 13:40:07 +0000 (21:40 +0800)] 
zip: remove unused central directory counters

Remove counters that are initialized or incremented but never read.

3 weeks agoMerge pull request #3206 from DHowett/win32-symlink-bypass
Dustin L. Howett [Thu, 2 Jul 2026 12:25:37 +0000 (07:25 -0500)] 
Merge pull request #3206 from DHowett/win32-symlink-bypass

3 weeks agowin32: prevent writing through a broken symlink in insecure mode 3223/head
Dustin L. Howett [Thu, 2 Jul 2026 01:47:18 +0000 (20:47 -0500)] 
win32: prevent writing through a broken symlink in insecure mode

The comments document that we were expecting O_EXCL behavior, and
archive_write_disk_posix uses O_EXCL as well. Let's use O_EXCL's nearest
equivalent.

3 weeks agoMerge pull request #3221 from stoeckmann/callback_data_check
Dustin L. Howett [Wed, 1 Jul 2026 21:04:34 +0000 (16:04 -0500)] 
Merge pull request #3221 from stoeckmann/callback_data_check

3 weeks agoCheck result of archive_read_set_callback_data 3221/head
Tobias Stoeckmann [Wed, 1 Jul 2026 20:38:58 +0000 (22:38 +0200)] 
Check result of archive_read_set_callback_data

The memory allocation in archive_read_set_callback_data2, which is
called by archive_read_set_callback_data, could fail.

Check result and properly handle failure.

Resolves #3210.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #3216 from setarcos/loongarch
Dustin L. Howett [Wed, 1 Jul 2026 17:03:18 +0000 (12:03 -0500)] 
Merge pull request #3216 from setarcos/loongarch

test: fix incorrect hole count reporting on loongarch64

3 weeks agoMerge pull request #3217 from datauwu/7zip-simplify-bool-handling
Dustin L. Howett [Wed, 1 Jul 2026 17:02:12 +0000 (12:02 -0500)] 
Merge pull request #3217 from datauwu/7zip-simplify-bool-handling

7zip: simplify bool handling

3 weeks agoMerge pull request #3218 from datauwu/7zip-redundant-bcj-assign
Dustin L. Howett [Wed, 1 Jul 2026 17:01:06 +0000 (12:01 -0500)] 
Merge pull request #3218 from datauwu/7zip-redundant-bcj-assign

7zip: drop redundant BCJ2 assignments

3 weeks ago7zip: simplify metadata bool handling 3217/head
datauwu [Wed, 1 Jul 2026 15:10:46 +0000 (23:10 +0800)] 
7zip: simplify metadata bool handling

Flatten nested allAreDefined checks for attribute and timestamp bools.

Also initialize empty-stream entries as directories by default before
applying the optional EmptyFile bitmap.

No archive behavior change is intended.

3 weeks ago7zip: drop redundant BCJ2 assignments 3218/head
datauwu [Wed, 1 Jul 2026 14:56:30 +0000 (22:56 +0800)] 
7zip: drop redundant BCJ2 assignments

Both supported BCJ2 layout branches store the chosen unpack size in
remaining.

main_stream_bytes_remaining is set from remaining immediately after
the branch, so the earlier assignments are redundant.

3 weeks agotest: fix incorrect hole count reporting on loongarch64 3216/head
Pluto Yang [Wed, 1 Jul 2026 12:57:14 +0000 (20:57 +0800)] 
test: fix incorrect hole count reporting on loongarch64

On LoongArch64 with 16KB pages, Linux tmpfs often uses Transparent
Huge Pages (THP) sized at 32MiB. When a test writes data followed
by a 32MiB hole, the kernel may allocate a single huge page folio
to back the entire range in RAM. Because the range is physically
backed by memory, SEEK_HOLE correctly (from the kernel's perspective)
identifies the range as DATA, failing the test's assertion. Increasing
MIN_HOLE to 64MiB ensures the hole exceeds the huge page size on
loongarch64, preserving the sparse nature of the file for the test.

Signed-off-by: Pluto Yang <yangyj.ee@gmail.com>
3 weeks agoMerge pull request #3213 from datauwu/7zip-remove-unused-state
Dustin L. Howett [Wed, 1 Jul 2026 13:13:55 +0000 (08:13 -0500)] 
Merge pull request #3213 from datauwu/7zip-remove-unused-state

3 weeks ago7zip: remove unused writer byte counters 3213/head
datauwu [Wed, 1 Jul 2026 09:38:25 +0000 (17:38 +0800)] 
7zip: remove unused writer byte counters

The 7z writer kept compressed and uncompressed byte counters that were
updated after each entry but never read.

Remove the counters and their updates.

3 weeks agoMerge pull request #3212 from stoeckmann/cab_doc_types
Dustin L. Howett [Tue, 30 Jun 2026 23:25:42 +0000 (18:25 -0500)] 
Merge pull request #3212 from stoeckmann/cab_doc_types

cab: Improve LZX translation readability

3 weeks agocab: Improve lzx_translation data types 3212/head
Tobias Stoeckmann [Tue, 30 Jun 2026 20:42:06 +0000 (22:42 +0200)] 
cab: Improve lzx_translation data types

Use correct data types to reduce amount of casts. This should further
improve readability.

While at it, also improve white space usage.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocab: Improve lzx_translation variable names
Tobias Stoeckmann [Tue, 30 Jun 2026 20:40:17 +0000 (22:40 +0200)] 
cab: Improve lzx_translation variable names

It's quite rare that "p" is not the iteration pointer but the base
pointer, while "b" is not the base pointer but the iteration pointer.

Use more descriptive variable names to assist auditors to figure out how
E8 call translation reversal works. It's already hard by itself.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocab: Turn translation size into int32_t
Tobias Stoeckmann [Tue, 30 Jun 2026 20:37:36 +0000 (22:37 +0200)] 
cab: Turn translation size into int32_t

It's a file size and used for signed integer comparison. Since it's
literally a file size, its maximum value should be properly checked as
well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocab: Document some magic numbers
Tobias Stoeckmann [Tue, 30 Jun 2026 20:36:29 +0000 (22:36 +0200)] 
cab: Document some magic numbers

Use more macro definitions instead of magic numbers to improve code
readability. Hopefully this explains a bit more where these values come
from.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agocab: Improve decoding status value description
Tobias Stoeckmann [Tue, 30 Jun 2026 20:33:32 +0000 (22:33 +0200)] 
cab: Improve decoding status value description

Move the macro definitions up to the field where they are used, which is
done for other such fields as well.

This in turn allows to avoid the magic value 0 in initial assignment.
Use ST_RD_TRANSLATION instead for better documentation where the finite
state machine starts (and that this state cannot be reached again).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agoMerge pull request #3207 from datauwu/tests-merge-fix-typo
Dustin L. Howett [Tue, 30 Jun 2026 16:33:06 +0000 (11:33 -0500)] 
Merge pull request #3207 from datauwu/tests-merge-fix-typo

tests: merge tests and fix misleading labels

4 weeks agoMerge pull request #3209 from datauwu/7zip-fix-sfx-boundary
Dustin L. Howett [Tue, 30 Jun 2026 16:26:17 +0000 (11:26 -0500)] 
Merge pull request #3209 from datauwu/7zip-fix-sfx-boundary

7zip: fix SFX boundary checks

4 weeks ago7zip: fix SFX boundary checks 3209/head
datauwu [Tue, 30 Jun 2026 13:46:55 +0000 (21:46 +0800)] 
7zip: fix SFX boundary checks

The SFX scanner missed a valid 7-Zip header when exactly 32 bytes
remained in the lookahead buffer.

The ELF SFX path also missed ".data" when it was at the last valid
position in the section string table. It also allowed e_shstrndx to be
equal to e_shnum, even though that is one past the section table.

Tighten these checks so valid edge cases are handled correctly.

4 weeks ago7zip: add SFX boundary tests
datauwu [Tue, 30 Jun 2026 13:46:54 +0000 (21:46 +0800)] 
7zip: add SFX boundary tests

Add PE and ELF SFX fixtures for the SFX scanner boundary cases.

The PE fixture places an empty 7z archive at the final exact
32-byte scan window. The ELF fixture places ".data\0" at the final
valid section string-table position.

Register the fixtures for autotools distcheck.

4 weeks agofuzz: fix iteration comment 3207/head
datauwu [Tue, 30 Jun 2026 09:12:12 +0000 (17:12 +0800)] 
fuzz: fix iteration comment

The fuzz test comment says each file is tested 100 times, but the
loop runs 1000 iterations. Update the comment to match the code.

4 weeks agozip: fix lzma/xz compression test name
datauwu [Tue, 30 Jun 2026 09:12:11 +0000 (17:12 +0800)] 
zip: fix lzma/xz compression test name

The ZIP compression test name used lzmaxz even though the test covers
the LZMA and XZ compression paths. Rename it to lzma_xz.

4 weeks agoiso9660: fix compress test names
datauwu [Tue, 30 Jun 2026 09:12:11 +0000 (17:12 +0800)] 
iso9660: fix compress test names

Several ISO tests used a bz2 suffix even though they read .Z files
and verify ARCHIVE_FILTER_COMPRESS. Rename them to use a compress
suffix so the test names match the filter.

4 weeks agoarchive_write: group option setter tests
datauwu [Tue, 30 Jun 2026 09:12:10 +0000 (17:12 +0800)] 
archive_write: group option setter tests

The write option setter checks used several tiny source files with the
same basic shape.

Keep the same DEFINE_TEST cases. Put the write-side option setter
checks in test_archive_write_set_options.c. Remove the extra source
files from the build lists.

4 weeks agoarchive_read: group option setter tests
datauwu [Tue, 30 Jun 2026 09:12:10 +0000 (17:12 +0800)] 
archive_read: group option setter tests

The read option setter checks used several tiny source files with the
same basic shape.

Keep the same DEFINE_TEST cases. Put the read-side option setter
checks in test_archive_read_set_options.c. Remove the extra source
files from the build lists.

4 weeks agoarchive_read: group close-twice tests
datauwu [Tue, 30 Jun 2026 09:12:09 +0000 (17:12 +0800)] 
archive_read: group close-twice tests

The close-twice read checks used three tiny source files.

Keep the same DEFINE_TEST cases. Put the fresh-object, fd-backed,
and filename-backed checks in one source file. Remove the two extra
files from the build lists.

4 weeks agotest: enable most of the remaining disk_secure tests on Windows 3206/head
Dustin L. Howett [Sat, 27 Jun 2026 18:29:44 +0000 (13:29 -0500)] 
test: enable most of the remaining disk_secure tests on Windows

This rather required porting them to assertIs{Reg,Dir,Symlink} and away
from lstat.

This is possible now that 9046e753cacfa5a1ce38aa1b8a259ca0364a0825 fixed
a number of other symlink issues on Windows.

4 weeks agoMerge commit from fork
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

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

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

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

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

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

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

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