]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
2 weeks agoGeneralize code to run on Windows 3013/head
Tim Kientzle [Fri, 8 May 2026 22:23:06 +0000 (15:23 -0700)] 
Generalize code to run on Windows

2 weeks agoInclude missing file
Tim Kientzle [Fri, 8 May 2026 04:37:08 +0000 (21:37 -0700)] 
Include missing file

2 weeks ago[XAR] Fix two UB
Tim Kientzle [Fri, 8 May 2026 04:11:54 +0000 (21:11 -0700)] 
[XAR] Fix two UB

1. The XAR writer's path normalization code uses strcpy() to move
   parts of a path string within the same buffer. The source and
   destination ranges overlap, which is undefined behavior for strcpy().

2. Failure to check string length before accessing the last character
   of a path component. For empty components (e.g., //), the length is 0,
   and length-1 underflows to SIZE_MAX.

2 weeks agoMerge pull request #3009 from kientzle/archive-read-sticky-fatal
Tim Kientzle [Thu, 7 May 2026 19:41:30 +0000 (12:41 -0700)] 
Merge pull request #3009 from kientzle/archive-read-sticky-fatal

Minor cleanups from #2298

2 weeks agoCleanup a new test, fill in some missing assertions 3009/head
Tim Kientzle [Thu, 7 May 2026 19:25:58 +0000 (12:25 -0700)] 
Cleanup a new test, fill in some missing assertions

2 weeks agoMerge pull request #2998 from kientzle/archive-read-sticky-fatal
Tim Kientzle [Thu, 7 May 2026 19:19:02 +0000 (12:19 -0700)] 
Merge pull request #2998 from kientzle/archive-read-sticky-fatal

archive_read: FATAL should be sticky for all API calls

2 weeks agoTODO seems to have been addressed; remove
Tim Kientzle [Thu, 7 May 2026 16:45:17 +0000 (09:45 -0700)] 
TODO seems to have been addressed; remove

2 weeks agoMerge pull request #3007 from jlduran/escape-vis-glob-chars
Tim Kientzle [Thu, 7 May 2026 15:34:11 +0000 (08:34 -0700)] 
Merge pull request #3007 from jlduran/escape-vis-glob-chars

mtree: Escape standard pathname matching characters

2 weeks agomtree: Escape standard pathname matching characters 3007/head
Jose Luis Duran [Wed, 15 Apr 2026 04:00:16 +0000 (04:00 +0000)] 
mtree: Escape standard pathname matching characters

Escape all strsvis(3) VIS_GLOB matching characters ('*', '?', '[', or
'#').

2 weeks agoRestore verbosity
Tim Kientzle [Thu, 7 May 2026 06:25:10 +0000 (23:25 -0700)] 
Restore verbosity

2 weeks agoFix CMake style
Tim Kientzle [Thu, 7 May 2026 06:24:53 +0000 (23:24 -0700)] 
Fix CMake style

2 weeks agoRestore switch_multivolume as needed 2998/head
Tim Kientzle [Thu, 7 May 2026 06:16:57 +0000 (23:16 -0700)] 
Restore switch_multivolume as needed

2 weeks agoAdjust tests
Tim Kientzle [Thu, 7 May 2026 05:15:11 +0000 (22:15 -0700)] 
Adjust tests

2 weeks agoFix CMake-based testing
Tim Kientzle [Thu, 7 May 2026 05:02:15 +0000 (22:02 -0700)] 
Fix CMake-based testing

2 weeks agoMake default test output verbose, for better CI info
Tim Kientzle [Thu, 7 May 2026 01:54:31 +0000 (18:54 -0700)] 
Make default test output verbose, for better CI info

2 weeks agoMerge pull request #3006 from stoeckmann/7zip_32
Tim Kientzle [Wed, 6 May 2026 18:52:11 +0000 (11:52 -0700)] 
Merge pull request #3006 from stoeckmann/7zip_32

7zip: Fix 32 bit heap overflow

2 weeks ago7zip: Fix more 32 bit truncations 3006/head
Tobias Stoeckmann [Mon, 27 Apr 2026 16:08:46 +0000 (18:08 +0200)] 
7zip: Fix more 32 bit truncations

Check for truncations before casting uint64_t to size_t for 32 bit
system safety.

Reported by Asaf Meizner.
Resolves additional notes in GHSA-rf5v-vf7c-6wvg.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks ago7zip: Fix 32 bit heap overflow
Asaf Meizner [Mon, 27 Apr 2026 15:56:35 +0000 (17:56 +0200)] 
7zip: Fix 32 bit heap overflow

Prevent an unsufficient memory allocation on 32 bit systems by checking
if a uint64_t value actually fits into size_t.

Resolves GHSA-rf5v-vf7c-6wvg.

2 weeks agoMerge branch 'master' into archive-read-sticky-fatal
Tim Kientzle [Wed, 6 May 2026 16:28:05 +0000 (09:28 -0700)] 
Merge branch 'master' into archive-read-sticky-fatal

2 weeks agoMerge pull request #3005 from kientzle/kientzle-automatic-test-discovery
Tim Kientzle [Wed, 6 May 2026 04:23:54 +0000 (21:23 -0700)] 
Merge pull request #3005 from kientzle/kientzle-automatic-test-discovery

[CMake] Automatically update `list.h`

2 weeks ago[CMake] Automatically update `list.h` 3005/head
Tim Kientzle [Wed, 6 May 2026 03:54:12 +0000 (20:54 -0700)] 
[CMake] Automatically update `list.h`

`list.h` contains a list of all the tests and is generated
by grepping the test source files for `DEFINE_TEST`.
Previously, it was generated at configure time.
This meant that if you added a new test to an existing
source file, you had to manually reconfigure.

This adds the necessary dependencies so that `list.h`
is regenerated whenever any C test source changes.
This ensures that new tests are always discovered automatically.

Note:  If someone wants to update the autoconf-based
build system to do this, please send a PR.

2 weeks agoMerge pull request #3000 from kientzle/kientzle-cab-hardening
Tim Kientzle [Wed, 6 May 2026 01:35:33 +0000 (18:35 -0700)] 
Merge pull request #3000 from kientzle/kientzle-cab-hardening

[CAB] Harden the handling of invalid headers

2 weeks agoMerge pull request #3004 from kientzle/kientzle-rar5-bad-tables
Tim Kientzle [Wed, 6 May 2026 01:34:22 +0000 (18:34 -0700)] 
Merge pull request #3004 from kientzle/kientzle-rar5-bad-tables

[RAR5] FAIL if the decode table is > 2^16

2 weeks agoRemove unused var 3004/head
Tim Kientzle [Wed, 6 May 2026 01:20:10 +0000 (18:20 -0700)] 
Remove unused var

2 weeks agoSolid archives cannot recover from a failed entry
Tim Kientzle [Wed, 6 May 2026 01:03:28 +0000 (18:03 -0700)] 
Solid archives cannot recover from a failed entry

2 weeks ago[RAR5] FAIL if the decode table is > 2^16
Tim Kientzle [Tue, 5 May 2026 22:43:48 +0000 (15:43 -0700)] 
[RAR5] FAIL if the decode table is > 2^16

2 weeks agoMerge pull request #3002 from kientzle/7zip-setup-decode-folder-state-order
Tim Kientzle [Tue, 5 May 2026 22:21:50 +0000 (15:21 -0700)] 
Merge pull request #3002 from kientzle/7zip-setup-decode-folder-state-order

[7zip] Clean up the failure path in `setup_decode_folder`

2 weeks agoMerge pull request #3003 from kientzle/kientzle-test-runner-name-args
Tim Kientzle [Tue, 5 May 2026 22:21:25 +0000 (15:21 -0700)] 
Merge pull request #3003 from kientzle/kientzle-test-runner-name-args

Clarify the test harness usage

2 weeks agoClarify the test harness usage 3003/head
Tim Kientzle [Tue, 5 May 2026 21:45:26 +0000 (14:45 -0700)] 
Clarify the test harness usage

2 weeks ago[7zip] Clean up the failure path in `setup_decode_folder` 3002/head
Tim Kientzle [Tue, 5 May 2026 21:12:15 +0000 (14:12 -0700)] 
[7zip] Clean up the failure path in `setup_decode_folder`

As noted by @dunhor, the logic here was a little unclear.
Reorganize to do all the checks, then set up the decode
parameters only if the checks pass.

This has no functional change, it's just a legibility improvement.

2 weeks ago[RAR5] Correct handling of unknown filter types
Tim Kientzle [Tue, 5 May 2026 17:00:01 +0000 (10:00 -0700)] 
[RAR5] Correct handling of unknown filter types

The change to return FAILED for entry-specific issues uncovered
flaws in RAR5 handling of filter types:
* Supported filter types are verified in `parse_filter` and
  were being also checked in `run_filter` -- the duplication
  confused the error handling here.
* `do_uncompress_file` was only checking for `FATAL` from
  the upstream filter logic, so failed to properly pass
  `FAILED` errors through

2 weeks ago[rar5] Fix infinite loop in header parsing
Tim Kientzle [Mon, 4 May 2026 23:38:15 +0000 (16:38 -0700)] 
[rar5] Fix infinite loop in header parsing

The change to return `FAILED` instead of `FATAL` for issues that
impact a single entry (but don't necessarily terminate the entire archive)
created a bug in header parsing since `FAILED` wasn't handled in a
header-check loop.

Thank goodness for fuzzing CI!

2 weeks ago7zip: propagate skip_stream's actual error code in read_data_skip
Tim Kientzle [Mon, 4 May 2026 03:42:22 +0000 (20:42 -0700)] 
7zip: propagate skip_stream's actual error code in read_data_skip

archive_read_format_7zip_read_data_skip used to coerce any negative
skip_stream() return into ARCHIVE_FATAL.  That is wrong in principle:
ARCHIVE_FAILED can legitimately propagate up from setup_decode_folder()
through read_stream() and skip_stream(), and the wrapper should not
upgrade it.

In the current encryption-partially test case this is empirically a
no-op because skip_stream() still returns ARCHIVE_FATAL via a second,
deeper code path through extract_pack_stream().  An inline TODO comment
flags that asymmetry for a follow-up audit.

2 weeks agorar5: convert remaining per-entry data errors to ARCHIVE_FAILED
Tim Kientzle [Mon, 4 May 2026 03:12:42 +0000 (20:12 -0700)] 
rar5: convert remaining per-entry data errors to ARCHIVE_FAILED

Follow-up to 9fa772ab.  An audit of the rar5 reader found many more
ARCHIVE_FATAL returns in data-decode paths that should be ARCHIVE_FAILED
so the caller can move on to the next entry after a corrupt one:

  apply_filters       Unsupported filter type
  parse_tables        Truncated huffman tables, decode failures (8 sites)
  parse_block_header  Unsupported header size, block checksum error
  do_uncompress_block Decode code length / distance slot failures
                      Distance pointer overflow
                      decode_number / decode_code_length failures
  merge_block         Block size == 0 during merge
  do_uncompress_file  Invalid window size declaration
  verify_checksums    CRC32 / BLAKE2 mismatch

Programmer assertions, ENOMEM, true I/O errors, and propagation of
copy_string's window-buf-NULL FATAL return are intentionally kept as
ARCHIVE_FATAL because they are not recoverable per-entry conditions.

2 weeks agorar: convert remaining per-entry data errors to ARCHIVE_FAILED
Tim Kientzle [Sun, 3 May 2026 23:25:55 +0000 (16:25 -0700)] 
rar: convert remaining per-entry data errors to ARCHIVE_FAILED

Follow-up to 4f148608.  A code review found additional ARCHIVE_FATAL
returns in RAR4 data-decode paths that should be ARCHIVE_FAILED so the
caller can move on to the next entry:

  read_data_block      Truncated RAR file data
  read_data_compressed PPMd "Invalid symbol" (3 sites)
  parse_codes          Zero window size is invalid
  add_value            Prefix found (second site)
  make_table_recurse   Huffman tree was not created
  make_table_recurse   Invalid location to Huffman tree specified

These are all per-entry parse/decode failures.  As with the earlier
batch, the rar4 input position is tracked by rar_br_fillup so
read_data_skip will correctly advance past the damaged entry, and
RAR4 solid mode is not supported, so subsequent entries are not at
risk from a half-consumed shared decoder state.

2 weeks agotests: update expected return codes from FATAL to FAILED
Tim Kientzle [Sun, 3 May 2026 22:23:48 +0000 (15:23 -0700)] 
tests: update expected return codes from FATAL to FAILED

Per-entry data errors (encryption, invalid filters, bad bitstream) now
return ARCHIVE_FAILED instead of ARCHIVE_FATAL.  Update tests that were
asserting the old incorrect ARCHIVE_FATAL return codes.

The one exception is test_read_format_7zip_encryption_partially line 71,
which asserts ARCHIVE_FATAL after archive_read_next_header on the entry
following an encrypted entry: 7zip cannot skip an encrypted entry (the
decode-folder setup fails), so the skip legitimately returns ARCHIVE_FATAL
and the archive is done.

2 weeks ago7zip: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors
Tim Kientzle [Sun, 3 May 2026 22:21:44 +0000 (15:21 -0700)] 
7zip: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors

setup_decode_folder() returned ARCHIVE_FATAL for both header-level and
data-level encryption/filter errors.  Header encryption is a true
archive-fatal condition; data encryption is per-entry.

Distinguish the two by returning ARCHIVE_FATAL when decoding archive
headers (header==1) and ARCHIVE_FAILED when decoding file content
(header==0).  Fix the call site in read_stream() to propagate the
actual return value rather than mapping all errors to ARCHIVE_FATAL.

2 weeks agorar5: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors
Tim Kientzle [Sun, 3 May 2026 22:21:21 +0000 (15:21 -0700)] 
rar5: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors

Two per-entry errors in the RAR5 data-reading path were returning
ARCHIVE_FATAL, preventing iteration over subsequent entries:

- "Reading encrypted data is not currently supported": the encryption
  is per-entry; unencrypted entries in the same archive remain readable.

- "Invalid filter encountered": a malformed filter spec in one entry
  does not make the rest of the archive unreadable.

Change both to ARCHIVE_FAILED.

2 weeks agorar: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors
Tim Kientzle [Sun, 3 May 2026 22:21:09 +0000 (15:21 -0700)] 
rar: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors

ARCHIVE_FATAL means the entire archive is unreadable and no further
operations are valid.  ARCHIVE_FAILED means the current entry cannot
be processed but iteration over subsequent entries may still succeed.

The RAR4 decompressor was returning ARCHIVE_FATAL from a large number
of data-parsing failures (invalid Huffman prefix, invalid PPMd sequence,
bad CRC, invalid symbol, etc.) that are per-entry errors.  Because each
entry's compressed data region can be skipped using the packed_size
recorded in its file header, a decompressor error does not prevent
reading the next entry's header.

Change all such per-entry errors in the data-reading path
(read_data_stored, read_data_compressed, parse_codes, create_code,
add_value, make_table_recurse, expand, copy_from_lzss_window,
copy_from_lzss_window_to_unp) to return ARCHIVE_FAILED.  OOM errors
and true I/O failures (rar_br_preparation truncated-data) remain
ARCHIVE_FATAL.

2 weeks agoarchive_read: make ARCHIVE_FATAL sticky in data-reading entry points
Tim Kientzle [Sun, 3 May 2026 22:20:33 +0000 (15:20 -0700)] 
archive_read: make ARCHIVE_FATAL sticky in data-reading entry points

Three entry points in archive_read.c could return ARCHIVE_FATAL from
the format layer without setting a->archive.state = ARCHIVE_STATE_FATAL,
so subsequent API calls would not see the archive as fatally broken:

- archive_read_data_skip() unconditionally reset state to HEADER even
  when the format's skip returned ARCHIVE_FATAL.

- archive_seek_data() and _archive_read_data_block() forwarded FATAL
  from the format layer without recording it in the archive state.

Fix all three so that ARCHIVE_FATAL causes the state to become
ARCHIVE_STATE_FATAL, consistent with the existing behavior of
archive_read_next_header().

2 weeks agoMerge pull request #3001 from kientzle/kientzle-7zip-test-more-tolerant
Tim Kientzle [Tue, 5 May 2026 00:43:13 +0000 (17:43 -0700)] 
Merge pull request #3001 from kientzle/kientzle-7zip-test-more-tolerant

Suppress spurious failures from old liblzma

2 weeks agoSuppress spurious failures from old liblzma 3001/head
Tim Kientzle [Tue, 5 May 2026 00:14:21 +0000 (17:14 -0700)] 
Suppress spurious failures from old liblzma

2 weeks ago[CAB] Harden the handling of invalid headers 3000/head
Tim Kientzle [Tue, 5 May 2026 00:01:33 +0000 (17:01 -0700)] 
[CAB] Harden the handling of invalid headers

Clear invalid data when a header is invalid.
Check for data being larger than the allocated buffer.

Thanks to @ReverseWarrior for pointing out this issue,
and providing the fix.

2 weeks agoMerge pull request #2992 from kientzle/kientzle-acl-isint-overflow
Tim Kientzle [Mon, 4 May 2026 03:04:03 +0000 (20:04 -0700)] 
Merge pull request #2992 from kientzle/kientzle-acl-isint-overflow

Expand ACL testing

2 weeks agoMerge pull request #2991 from kientzle/kientzle-tar-timestamp-hardening
Tim Kientzle [Sun, 3 May 2026 22:23:22 +0000 (15:23 -0700)] 
Merge pull request #2991 from kientzle/kientzle-tar-timestamp-hardening

[tar] Harden timestamp parsing

2 weeks agoUse `time_t` return for a `time_t` value 2991/head
Tim Kientzle [Sun, 3 May 2026 21:43:10 +0000 (14:43 -0700)] 
Use `time_t` return for a `time_t` value

2 weeks agoMerge pull request #2996 from kientzle/kientzle-zip-empty-pathname
Tim Kientzle [Sun, 3 May 2026 21:33:34 +0000 (14:33 -0700)] 
Merge pull request #2996 from kientzle/kientzle-zip-empty-pathname

[Zip] Reject empty pathnames in ZIP writer

2 weeks agoMerge branch 'master' into kientzle-zip-empty-pathname 2996/head
Tim Kientzle [Sun, 3 May 2026 16:38:55 +0000 (09:38 -0700)] 
Merge branch 'master' into kientzle-zip-empty-pathname

2 weeks agoMerge pull request #2993 from kientzle/kientzle-zip-long-pathnames
Tim Kientzle [Sun, 3 May 2026 16:36:26 +0000 (09:36 -0700)] 
Merge pull request #2993 from kientzle/kientzle-zip-long-pathnames

[Zip] Don't try to write overlong pathnames

2 weeks ago[Zip] Reject empty pathnames in ZIP writer
Tim Kientzle [Sun, 3 May 2026 16:32:00 +0000 (09:32 -0700)] 
[Zip] Reject empty pathnames in ZIP writer

An empty pathname caused a one-byte OOB read before the heap buffer in
write_path() due to two compounding bugs:
(1) misuse of bitwise & instead of logical &&, and
(2) missing gaurd for an empty pathname

2 weeks ago[Zip] Reject overlong pathnames in Zip writer 2993/head
Tim Kientzle [Sat, 2 May 2026 23:52:35 +0000 (16:52 -0700)] 
[Zip] Reject overlong pathnames in Zip writer

2 weeks agoTest writing overlong Zip pathnames
Tim Kientzle [Sat, 2 May 2026 23:52:19 +0000 (16:52 -0700)] 
Test writing overlong Zip pathnames

2 weeks ago[ACL] Add more tests for POSIX.1e ACLs 2992/head
Tim Kientzle [Sat, 2 May 2026 23:23:32 +0000 (16:23 -0700)] 
[ACL] Add more tests for POSIX.1e ACLs

This mirrors the tests just added for NFS4 ACLs.  They
didn't uncover any problems.

2 weeks ago[archive_acl] Reject ACL entries with out-of-range numeric IDs
Tim Kientzle [Sat, 2 May 2026 18:51:47 +0000 (11:51 -0700)] 
[archive_acl] Reject ACL entries with out-of-range numeric IDs

isint() and isint_w() previously clamped values >= INT_MAX to INT_MAX
and returned success, allowing malformed ACL text to silently set IDs
to an arbitrary sentinel value.  Change them to return -1 (a new
"overflow" indication) instead, and update all callers in both the
NFS4 and POSIX parsers (narrow and wide) to treat overflow as
ARCHIVE_WARN and skip the offending entry.

Add test_acl_nfs4_text.c with four test functions covering NFS4 ACL
text round-trips, audit/alarm entry types, numeric-ID handling
including the overflow boundary (INT_MAX - 1 accepted, INT_MAX
rejected), and malformed-entry error paths.

2 weeks ago[tar] Harden timestamp parsing
Tim Kientzle [Sat, 2 May 2026 20:58:45 +0000 (13:58 -0700)] 
[tar] Harden timestamp parsing

Improves the parsing of timestamps in a couple of ways:

* Saturate when timestamps exceed the range of time_t.
  In particular, this provides more rational behavior on
  systems with 32-bit time_t.

* Validate the format of overlong pax timestamps.
  We previously failed to check that high-resolution
  timestamps had only digits in the fractional part.
  We now notice and ignore those with a warning.

2 weeks agoMerge pull request #2990 from kientzle/kientzle-gitignore-AI-files
Tim Kientzle [Sat, 2 May 2026 19:05:07 +0000 (15:05 -0400)] 
Merge pull request #2990 from kientzle/kientzle-gitignore-AI-files

Ignore local CLAUDE/GEMINI files

2 weeks agoIgnore local CLAUDE/GEMINI files 2990/head
Tim Kientzle [Sat, 2 May 2026 19:03:57 +0000 (12:03 -0700)] 
Ignore local CLAUDE/GEMINI files

2 weeks agoMerge pull request #2989 from kientzle/kientzle-test-documentation
Tim Kientzle [Sat, 2 May 2026 19:02:14 +0000 (15:02 -0400)] 
Merge pull request #2989 from kientzle/kientzle-test-documentation

Minor clarification on test discovery

2 weeks agoMinor clarification on test discovery 2989/head
Tim Kientzle [Sat, 2 May 2026 19:00:33 +0000 (12:00 -0700)] 
Minor clarification on test discovery

2 weeks agoMerge pull request #2985 from stoeckmann/7zip_sfx
Martin Matuška [Sat, 2 May 2026 18:48:01 +0000 (20:48 +0200)] 
Merge pull request #2985 from stoeckmann/7zip_sfx

7zip: Harden SFX parser

2 weeks agoMerge pull request #2988 from kientzle/kientzle-acl-to-text
Martin Matuška [Sat, 2 May 2026 18:43:56 +0000 (20:43 +0200)] 
Merge pull request #2988 from kientzle/kientzle-acl-to-text

[archive_acl] Fix buffer overrun and wrong output for NULL-name ACL entries

2 weeks agoarchive_acl: Fix buffer overrun and wrong output for NULL-name ACL entries 2988/head
Tim Kientzle [Sat, 2 May 2026 16:46:06 +0000 (09:46 -0700)] 
archive_acl: Fix buffer overrun and wrong output for NULL-name ACL entries

archive_acl_text_len() counted the trailing ":id" digits only when
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID was set, but archive_acl_to_text_l()
always writes them for USER/GROUP entries whose name is NULL.  With a
7-digit or larger id the allocated buffer was too short, causing
append_id() to write past its end.

Fix the estimator to also count the extra colon and digits when the
name is NULL, matching the serializer's logic.

The wide serializer (archive_acl_to_text_w) had the opposite problem:
it passed id=-1 to append_entry_w() for NULL-name entries regardless
of the id value, causing a garbage character to be written in the name
field and the numeric id to be omitted entirely.  Fix it to mirror the
narrow serializer by setting id = ap->id when wname is NULL.

Add tests for both the narrow and wide paths.

3 weeks agoMerge pull request #2983 from kientzle/kientzle-iso9660-joliet-pathname
Tim Kientzle [Sat, 2 May 2026 16:09:47 +0000 (12:09 -0400)] 
Merge pull request #2983 from kientzle/kientzle-iso9660-joliet-pathname

[iso9660] Fix joliet pathname overflow

3 weeks agoMerge pull request #2973 from dag-erling/des/darwin-crypto
Tim Kientzle [Sat, 2 May 2026 16:07:28 +0000 (12:07 -0400)] 
Merge pull request #2973 from dag-erling/des/darwin-crypto

On Darwin, get digests from libsystem

3 weeks agoconfigure: On Darwin, get digests from libsystem 2973/head
Dag-Erling Smørgrav [Mon, 20 Apr 2026 18:31:28 +0000 (20:31 +0200)] 
configure: On Darwin, get digests from libsystem

Darwin covers a wide range of platforms with similar but not identical
sets of libraries.  MD5, SHA1 and SHA2 are available from libsystem on
all of these, but macOS also has them in libc and libmd.  Restricting
our search to only libsystem means we can run configure on macOS and get
a config.h that also works for other Darwin platforms.

3 weeks ago7zip: Fix typos in comment 2985/head
Tobias Stoeckmann [Mon, 27 Apr 2026 18:15:44 +0000 (20:15 +0200)] 
7zip: Fix typos in comment

Also clarify that all systems will handle these SFX files, no matter on
which system libarchive is used.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Cap maximum allocation for SFX handling
Tobias Stoeckmann [Mon, 27 Apr 2026 17:58:05 +0000 (19:58 +0200)] 
7zip: Cap maximum allocation for SFX handling

If 7zip header cannot be found within roughly first 8 MB of data, skip
detection and assume that file is not a valid 7zip archive.

This avoids various 32 bit truncation issues as well as out of memory
conditions.

Reported by various individuals:
- Amemoyoi
- b4sh5i
- Jie Zhu
- Tikket
- wooseokdotkim

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Be precise about SFX data types
Tobias Stoeckmann [Mon, 27 Apr 2026 17:45:10 +0000 (19:45 +0200)] 
7zip: Be precise about SFX data types

Use desired data types: Offsets in files are (u)int64_t, sizes in memory
are (s)size_t. Use signedness when needed or specified by APIs.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Adjust sfx offset function signatures
Tobias Stoeckmann [Mon, 27 Apr 2026 17:24:15 +0000 (19:24 +0200)] 
7zip: Adjust sfx offset function signatures

Return an int for error information and supply offset through a given
argument. This fits other function declarations and makes it much easier
to differentiate between status and "return value".

While at it, merge fallback mechanism of both functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Merge skip_sfx into get_data_offset
Tobias Stoeckmann [Mon, 27 Apr 2026 17:13:17 +0000 (19:13 +0200)] 
7zip: Merge skip_sfx into get_data_offset

This removes the function skip_sfx which makes slurp_central_directory
and archive_read_format_7zip_bid use the same code now.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Introduce get_data_offset
Tobias Stoeckmann [Mon, 27 Apr 2026 17:05:39 +0000 (19:05 +0200)] 
7zip: Introduce get_data_offset

Its functionality is split off from archive_read_format_7zip_bid
and returns offset to actual data, i.e. it handles self extracting
(SFX) files if offset 0 is not already a 7zip magic.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Reduce archive_read_format_7zip_bid depth
Tobias Stoeckmann [Mon, 27 Apr 2026 16:55:13 +0000 (18:55 +0200)] 
7zip: Reduce archive_read_format_7zip_bid depth

Prepare content of archive_read_format_7zip_bid to be split into its own
function which eventually can be reused by slurp_central_directory.

No real functional change (split if-blocks).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks ago7zip: Remove casts in check_7zip_header_in_sfx
Tobias Stoeckmann [Mon, 27 Apr 2026 16:40:37 +0000 (18:40 +0200)] 
7zip: Remove casts in check_7zip_header_in_sfx

Directly request an unsigned char pointer. This removes casts within the
function check_7zip_header_in_sfx and its surrounding caller code.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoFix joliet pathname buffer overflow 2983/head
Tim Kientzle [Sun, 26 Apr 2026 22:22:10 +0000 (18:22 -0400)] 
Fix joliet pathname buffer overflow

3 weeks ago[ISO9660] Test for buffer overflows with Joliet pathname building
Tim Kientzle [Sun, 26 Apr 2026 22:20:57 +0000 (18:20 -0400)] 
[ISO9660] Test for buffer overflows with Joliet pathname building

Credit: Anthropic

3 weeks agoMerge pull request #2526 from fdegros/compress_support
Tim Kientzle [Sat, 25 Apr 2026 20:51:46 +0000 (16:51 -0400)] 
Merge pull request #2526 from fdegros/compress_support

Fix SIGSEGV in compress filter when appended before open

3 weeks agoMerge pull request #2980 from kientzle/kientzle-7zip-numfiles
Tim Kientzle [Sat, 25 Apr 2026 20:42:06 +0000 (16:42 -0400)] 
Merge pull request #2980 from kientzle/kientzle-7zip-numfiles

[7zip] Sanity-check the number of files

3 weeks ago[7zip] Sanity-check the number of files 2980/head
Tim Kientzle [Sat, 25 Apr 2026 18:58:17 +0000 (14:58 -0400)] 
[7zip] Sanity-check the number of files

We allocate space early on to support the advertised number of
files. A malicious archive can set a nonsensical value here to exhaust
memory. This adds a check comparing the number of files to the number
of streams and the size of the total header.

Note that the just-added test does not actually fail without this.
The existing code recovers if the allocation fails, which it typically
will.  The new check tightens the limit so that we reject nonsensical
file counts and avoid problems from large memory allocations.

3 weeks agoMerge pull request #2981 from kientzle/kientzle-zip-lzma-memory
Tim Kientzle [Sat, 25 Apr 2026 18:57:19 +0000 (14:57 -0400)] 
Merge pull request #2981 from kientzle/kientzle-zip-lzma-memory

[Zip] Limit the LZMA initialization to 64MiB memory

3 weeks agoMerge pull request #2964 from kientzle/kientzle-test-documentation
Tim Kientzle [Sat, 25 Apr 2026 18:51:42 +0000 (14:51 -0400)] 
Merge pull request #2964 from kientzle/kientzle-test-documentation

Document how to write new tests and how to build and run test suites

3 weeks ago[7zip] Test extracting an archive with a malicious file count
Tim Kientzle [Sat, 25 Apr 2026 18:48:34 +0000 (14:48 -0400)] 
[7zip] Test extracting an archive with a malicious file count

This currently results in an oversized allocation that can
exhaust available memory.

3 weeks agoLimit LZMA memory allocation to 576MiB 2981/head
Tim Kientzle [Sat, 25 Apr 2026 18:39:28 +0000 (14:39 -0400)] 
Limit LZMA memory allocation to 576MiB

Reject Zip entries that declare an LZMA dictionary size
greater than the maximum possible with Level 9 compression.

3 weeks agoTest extracting Zip Lzma entry with a malicious dictionary size
Tim Kientzle [Sat, 25 Apr 2026 18:32:32 +0000 (14:32 -0400)] 
Test extracting Zip Lzma entry with a malicious dictionary size

4 weeks agoAdditional adjustments 2964/head
Tim Kientzle [Sat, 25 Apr 2026 01:50:42 +0000 (21:50 -0400)] 
Additional adjustments

4 weeks agoMerge pull request #2979 from tyler-yankee/cab-huffman-memcheck
Tim Kientzle [Fri, 24 Apr 2026 23:44:26 +0000 (19:44 -0400)] 
Merge pull request #2979 from tyler-yankee/cab-huffman-memcheck

cab reader: Fix use of uninitialized values from Huffman table

4 weeks agoAdd tests for appending various filters before archive open 2526/head
François Degros [Fri, 24 Apr 2026 07:34:10 +0000 (17:34 +1000)] 
Add tests for appending various filters before archive open

Extend test coverage to ensure all supported filters can be appended
to an archive reader before it is opened, matching the behavior
required to fix #2514.

Added tests for: BZIP2, LRZIP, LZ4, LZIP, LZMA, ZSTD, RPM, UU, and NONE.

4 weeks agoFix SIGSEGV in compress filter when appended before open
François Degros [Fri, 24 Apr 2026 07:09:13 +0000 (17:09 +1000)] 
Fix SIGSEGV in compress filter when appended before open

Calling archive_read_append_filter(a, ARCHIVE_FILTER_COMPRESS) would
previously trigger a crash because compress_bidder_init() attempted to
read header bits from the upstream filter immediately. If the archive
was not yet opened (common when setting up filters), the upstream filter
state was not ready for reading.

This commit defers the header reading and decompressor initialization
until the first read operation (lazy initialization), consistent with
other filter implementations in libarchive.

Added test_read_append_compress_filter.

Bug: https://github.com/libarchive/libarchive/issues/2514
Test: ./libarchive_test test_read_append_compress_filter

4 weeks agocab reader: Fix use of uninitialized values from Huffman table 2979/head
Tyler Yankee [Thu, 23 Apr 2026 12:02:52 +0000 (08:02 -0400)] 
cab reader: Fix use of uninitialized values from Huffman table

Initialize the Huffman table to invalid values, which doesn't otherwise
affect the computation but avoids use of uninitialized values upon
extraction of some archives (as reported by `valgrind`).

4 weeks agoMerge pull request #2966 from solbjorn/win-crypt-unforce
Tim Kientzle [Wed, 22 Apr 2026 01:09:17 +0000 (18:09 -0700)] 
Merge pull request #2966 from solbjorn/win-crypt-unforce

libarchive: fix Windows compilation with `ENABLE_CNG=OFF`

4 weeks agolibarchive: fix Windows compilation with ENABLE_CNG=OFF 2966/head
Alexander Lobakin [Tue, 21 Apr 2026 20:50:18 +0000 (22:50 +0200)] 
libarchive: fix Windows compilation with ENABLE_CNG=OFF

Currently, libarchive_{random,util}.c use a couple bcrypt functions
regardless of whether HAVE_BCRYPT_H is defined as there are no other
implementations for Windows, but the actual <bcrypt.h> header is
included only under this macro.

To be able to build libarchive with ENABLE_CNG=OFF (for example, to
prefer a different crypto/digest engine) on Windows, don't guard
the include in these two files. In that case, bcrypt will still be
used, but only as an RNG.
This won't break anything because, as mentioned above, bcrypt is
used unconditionally here and if it's not present in the system,
the library won't build either way, with or without the change.
At least until we implement an RNG for Windows based on something
else.

Signed-off-by: Alexander Lobakin <alobakin@mailbox.org>
4 weeks agoMerge pull request #2971 from stoeckmann/asan_memleak
Tim Kientzle [Tue, 21 Apr 2026 01:56:35 +0000 (18:56 -0700)] 
Merge pull request #2971 from stoeckmann/asan_memleak

Fix mem leaks found with ASAN-enabled test suites

4 weeks agoMerge pull request #2970 from stoeckmann/gitignore
Tim Kientzle [Tue, 21 Apr 2026 01:54:43 +0000 (18:54 -0700)] 
Merge pull request #2970 from stoeckmann/gitignore

build: Add more entries to .gitignore

4 weeks agoFix memory leaks in test suites 2971/head
Tobias Stoeckmann [Mon, 20 Apr 2026 17:09:05 +0000 (19:09 +0200)] 
Fix memory leaks in test suites

Release memory so ASAN becomes a viable option for test suites.

4 weeks agomtree: Always release digest memory
Tobias Stoeckmann [Mon, 20 Apr 2026 17:07:48 +0000 (19:07 +0200)] 
mtree: Always release digest memory

If a checksum has been provided through archive_entry and no data is
written, then digest internal memory is not released.

Fix this by always calling final functions, even if result is not
needed.

4 weeks agotar: Release memory on error path
Tobias Stoeckmann [Mon, 20 Apr 2026 17:06:11 +0000 (19:06 +0200)] 
tar: Release memory on error path

Release attr_name memory on error paths.

Fixes: 101646e34e88 ("tar: Keep block alignment after pax error")
Fixes: 36a530973a91 ("Fix an infinite loop when parsing `V` headers")
4 weeks agobuild: Add more entries to .gitignore 2970/head
Tobias Stoeckmann [Mon, 20 Apr 2026 16:05:19 +0000 (18:05 +0200)] 
build: Add more entries to .gitignore

Using cmake within VSCode leads to creation of files which are not covered
by .gitignore so far. Covers Linux and Windows builds.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agoMerge pull request #2968 from stoeckmann/isofile_gen_utility_names_dotdot
Tim Kientzle [Sun, 19 Apr 2026 20:42:53 +0000 (13:42 -0700)] 
Merge pull request #2968 from stoeckmann/isofile_gen_utility_names_dotdot

iso9660: Fix `..` (dot dot) path normalization

4 weeks agoiso9660: Fix ../../ path normalization 2968/head
Tobias Stoeckmann [Sun, 19 Apr 2026 20:10:10 +0000 (22:10 +0200)] 
iso9660: Fix ../../ path normalization

The function isofile_gen_utility_names could resolve .. directory
entries in a way that dirname will start with "../". If this happens,
the while-loop is unable to detect this because it forwards until the
cursor detects a slash again.

Fix this by also taking "../" at the beginning into account. Such an
entry can happen if "../../" points before the top directory.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agoiso9660: Add adjacent dot dot issue to test suite
Tobias Stoeckmann [Sun, 19 Apr 2026 20:08:23 +0000 (22:08 +0200)] 
iso9660: Add adjacent dot dot issue to test suite

If dot dot directory entries point before top directory, it can happen
that "../" will stay at the start of the path.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 weeks agoiso9660: Handle multiple slashes after dot dot
Tobias Stoeckmann [Sun, 19 Apr 2026 20:02:29 +0000 (22:02 +0200)] 
iso9660: Handle multiple slashes after dot dot

The isofile_gen_utility_names function normalizes directories, including
dot dot directory entries. If such an entry has multiple slahes and leads
to the top directory, then the new path erroneously becomes absolute.

Skip multiple slashes.

If rp is not NULL, then it points to a slash already. Takes this into
account to unify the rp and dirname cases a bit more.

Resolves #2937.

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