]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
8 weeks agoSkip zlib tests if support is missing 2658/head
Tobias Stoeckmann [Tue, 3 Jun 2025 15:24:30 +0000 (17:24 +0200)] 
Skip zlib tests if support is missing

If zlib is not supported, do not run tests to avoid false positives.

Also adjust tests to support latest gzip versions (1.10+) which store
less information for improved reproducibility. The gzip binary is
used as a fallback if zlib is not available.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 weeks agoSkip lzma test if support is missing
Tobias Stoeckmann [Mon, 2 Jun 2025 19:42:39 +0000 (21:42 +0200)] 
Skip lzma test if support is missing

If lzma is not supported, do not run tests to avoid false positives.

Fixes https://github.com/libarchive/libarchive/issues/2647

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 weeks agoSkip KOI8 conversion test if support is missing
Tobias Stoeckmann [Mon, 2 Jun 2025 19:41:09 +0000 (21:41 +0200)] 
Skip KOI8 conversion test if support is missing

If a unix system has no iconv support, the best effort function will
be unable to convert KOI8 to UTF-8. Skip the test if such support is
missing.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 weeks agounzip: Pass test if encryption support is missing
Tobias Stoeckmann [Mon, 2 Jun 2025 19:38:11 +0000 (21:38 +0200)] 
unzip: Pass test if encryption support is missing

If no encryption support exists, the -P option will always fail.
"Skip" the test by making sure that there really is no encryption
support according to libarchive functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 weeks agozip: Better detect no encryption support
Tobias Stoeckmann [Mon, 2 Jun 2025 19:20:58 +0000 (21:20 +0200)] 
zip: Better detect no encryption support

Some functions might return -1 in case of library error. Use an
own return value if a stub function was used for better error
messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 weeks agoMerge pull request #2660 from kevans91/ke/fix-fortify
Tim Kientzle [Tue, 3 Jun 2025 13:02:09 +0000 (06:02 -0700)] 
Merge pull request #2660 from kevans91/ke/fix-fortify

libarchive/test: fix build when memcpy() is a macro

8 weeks agolibarchive/test: fix build when memcpy() is a macro 2660/head
Kyle Evans [Tue, 3 Jun 2025 02:43:28 +0000 (21:43 -0500)] 
libarchive/test: fix build when memcpy() is a macro

After importing the latest libarchive into FreeBSD, Shawn Webb @
HardenedBSD noted that the test build is broken when FORTIFY_SOURCE=2
while building the base system.  Braced initializer lists are a special
case that need some extra fun parentheses when we're dealing with the
preprocessor.

While it's not a particularly common setup, the extra parentheses don't
really hurt readability all that much so it's worth fixing for wider
compatibility.

Fixes: libarchive/libarchive#2657
8 weeks agoMerge pull request #2655 from mmatuska/fix/setclocale
Tim Kientzle [Sun, 1 Jun 2025 23:04:49 +0000 (16:04 -0700)] 
Merge pull request #2655 from mmatuska/fix/setclocale

test_utils/test_main.c: satisfy -Wstrict-prototypes

8 weeks agotest_utils/test_main.c: satisfy -Wstrict-prototypes 2655/head
Martin Matuska [Sun, 1 Jun 2025 21:35:05 +0000 (23:35 +0200)] 
test_utils/test_main.c: satisfy -Wstrict-prototypes

8 weeks agoMerge pull request #2627 from heirecka/do-not-hard-code-pkg-config
Martin Matuška [Sat, 31 May 2025 19:40:04 +0000 (21:40 +0200)] 
Merge pull request #2627 from heirecka/do-not-hard-code-pkg-config

Use PKG_CONFIG instead of hard-coded pkg-config

8 weeks agoMerge pull request #2643 from stoeckmann/tar_pax_sparse
Martin Matuška [Sat, 31 May 2025 19:31:14 +0000 (21:31 +0200)] 
Merge pull request #2643 from stoeckmann/tar_pax_sparse

tar: Handle extra bytes after sparse entries

8 weeks agoMerge pull request #2652 from stoeckmann/wstring_ensure
Tim Kientzle [Sat, 31 May 2025 14:16:07 +0000 (07:16 -0700)] 
Merge pull request #2652 from stoeckmann/wstring_ensure

Check archive_wstring_ensure return value

2 months agoAlways check archive_wstring_ensure return value 2652/head
Tobias Stoeckmann [Sat, 31 May 2025 09:33:07 +0000 (11:33 +0200)] 
Always check archive_wstring_ensure return value

Memory allocation might fail, so check if it was successful.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agowrite disk windows: Release memory on error paths
Tobias Stoeckmann [Sat, 31 May 2025 09:31:50 +0000 (11:31 +0200)] 
write disk windows: Release memory on error paths

Free wsp in case of out of memory condition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoiso9660: Check another archive_string_ensure result
Tobias Stoeckmann [Sat, 31 May 2025 07:46:17 +0000 (09:46 +0200)] 
iso9660: Check another archive_string_ensure result

Missed one unchecked archive_string_ensure in the previous commit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2651 from stoeckmann/string_ensure_check
Tim Kientzle [Sat, 31 May 2025 02:50:25 +0000 (19:50 -0700)] 
Merge pull request #2651 from stoeckmann/string_ensure_check

Always check archive_string_ensure return value

2 months agoMerge pull request #2648 from stoeckmann/test_en_us
Tim Kientzle [Sat, 31 May 2025 02:35:44 +0000 (19:35 -0700)] 
Merge pull request #2648 from stoeckmann/test_en_us

test_utils: Enforce C locale for all tests

2 months agoMerge pull request #2650 from stoeckmann/string_sort
Tim Kientzle [Sat, 31 May 2025 02:33:34 +0000 (19:33 -0700)] 
Merge pull request #2650 from stoeckmann/string_sort

archive_utility_string_sort: Use qsort directly

2 months agoAlways check archive_string_ensure return value 2651/head
Tobias Stoeckmann [Fri, 30 May 2025 21:41:21 +0000 (23:41 +0200)] 
Always check archive_string_ensure return value

Memory allocation might fail, so check if it was successful.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoRemove archive_utility_string_sort with 4.0.0 2650/head
Tobias Stoeckmann [Fri, 30 May 2025 15:41:26 +0000 (17:41 +0200)] 
Remove archive_utility_string_sort with 4.0.0

The archive_utility_string_sort function won't be part of the 4.0.0 API
anymore. No users were found and such a task should be done outside of
the library.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_utility_string_sort: Use qsort directly
Tobias Stoeckmann [Thu, 29 May 2025 16:19:47 +0000 (18:19 +0200)] 
archive_utility_string_sort: Use qsort directly

The utility function "archive_utility_string_sort" is a custom qsort
implementation. Since qsort is specified in C11 and POSIX.1-2008
which libarchive is based on, use system's qsort directly.

The function is not used directly in libarchive, so this is a good
way to save around 500 bytes in resulting library without breaking
compatibility for any user of this function (none found).

Also allows more than UINT_MAX entries which previously were limited
by data type and (way earlier) due to recursion.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotest_list_item: Do not modify LC_TIME 2648/head
Tobias Stoeckmann [Fri, 30 May 2025 15:33:19 +0000 (17:33 +0200)] 
test_list_item: Do not modify LC_TIME

Test cases already get a C locale, which is sufficient for this test.
IF LC_TIME was not previously set, the used en_US.UTF-8 would stay
as an environment variable, possibly affecting other test cases.
Since en_US.UTF-8 is not guaranteed to be available, C is a better
choice.

Fixes https://github.com/libarchive/libarchive/issues/2560

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotest_utils: Reset all locale related entries
Tobias Stoeckmann [Fri, 30 May 2025 15:32:02 +0000 (17:32 +0200)] 
test_utils: Reset all locale related entries

Reset current locale settings through setlocale and also all
environment variables which might affect test cases which
spawn children through systemf which in turn would call setlocale
on their own, e.g. bsdtar.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2634 from stoeckmann/tar_neg_time
Tim Kientzle [Fri, 30 May 2025 00:31:28 +0000 (17:31 -0700)] 
Merge pull request #2634 from stoeckmann/tar_neg_time

tar: Support negative time values with pax

2 months agoMerge pull request #2649 from stoeckmann/compress_recursion
Tim Kientzle [Thu, 29 May 2025 23:37:44 +0000 (16:37 -0700)] 
Merge pull request #2649 from stoeckmann/compress_recursion

compress: Prevent call stack overflow

2 months agocompress: Prevent call stack overflow 2649/head
Tobias Stoeckmann [Thu, 29 May 2025 13:07:02 +0000 (15:07 +0200)] 
compress: Prevent call stack overflow

Explicitly use goto to turn a recursive call into an iterative one.
Most compilers do this on their own with default settings, but MSVC
with default settings would create a binary which actually performs
recursive calls.

Fixes call stack overflow in binaries compiled with low optimization.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2642 from stoeckmann/seek_regress
Tim Kientzle [Wed, 28 May 2025 03:55:15 +0000 (20:55 -0700)] 
Merge pull request #2642 from stoeckmann/seek_regress

Fix FILE_skip regression

2 months agoMerge pull request #2644 from stoeckmann/tar_neg_size
Tim Kientzle [Wed, 28 May 2025 03:52:36 +0000 (20:52 -0700)] 
Merge pull request #2644 from stoeckmann/tar_neg_size

tar: Always treat negative sizes as error

2 months agoMerge pull request #2645 from stoeckmann/tar_formatter
Tim Kientzle [Wed, 28 May 2025 03:43:46 +0000 (20:43 -0700)] 
Merge pull request #2645 from stoeckmann/tar_formatter

tar: Fix archive_set_error formatters

2 months agoMerge pull request #2646 from stoeckmann/sparse32
Tim Kientzle [Wed, 28 May 2025 03:41:19 +0000 (20:41 -0700)] 
Merge pull request #2646 from stoeckmann/sparse32

tar: Handle many sparse comments on 32 bit systems

2 months agotar: Handle many sparse comments on 32 bit systems 2646/head
Tobias Stoeckmann [Tue, 27 May 2025 19:08:55 +0000 (21:08 +0200)] 
tar: Handle many sparse comments on 32 bit systems

The sparse 1.0 parser skips lines with comments. The amount of skipped
bytes is stored in a ssize_t variable, although common 32 bit systems
allow files larger than 4 GB.

Gracefully handle files with more than 2 GB bytes full of comments to
prevent integer truncations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Fix archive_set_error formatters 2645/head
Tobias Stoeckmann [Tue, 27 May 2025 18:45:55 +0000 (20:45 +0200)] 
tar: Fix archive_set_error formatters

Use correct formatters and casts with newly introduced ll
length modifier.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Always treat negative sizes as error 2644/head
Tobias Stoeckmann [Tue, 27 May 2025 18:30:01 +0000 (20:30 +0200)] 
tar: Always treat negative sizes as error

If a pax global header specifies a negative size, it is possible to
reduce variable `unconsumed` by 512 bytes, leading to a re-reading
of the pax global header. Fortunately the loop verifies that only one
global header per entry is allowed, leading to a later ARCHIVE_FATAL.

Avoid any form of negative size handling and fail early.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Handle extra bytes after sparse entries 2643/head
Tobias Stoeckmann [Tue, 27 May 2025 17:57:05 +0000 (19:57 +0200)] 
tar: Handle extra bytes after sparse entries

Skip all entry bytes after sparse entries were encountered. This matches
GNU tar behavior.

I have adjusted (and fixed) the existing test case for this. The test
case test_read_format_gtar_sparse_skip_entry did not work with GNU tar.

In #2558 it was explained that the pax size always overrides the header
size (correct). Since the pax size in the test case was way larger than
the actual entry bytes in archive, GNU tar choke on the test file.

The libarchive parser did not skip any bytes not already read due to
references by sparse entries, so the huge pax size was not detected.

By adjusting the test case to have a leftover byte (only 3 bytes are
referenced through sparse entry now, leaving one extra byte) with a
correct pax size and an invalid header size (after all it is overridden
by pax size), GNU tar works and libarchive gets off its 512 byte
alignment, not being able to read the next entry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoFix FILE_skip regression 2642/head
Tobias Stoeckmann [Tue, 27 May 2025 15:09:12 +0000 (17:09 +0200)] 
Fix FILE_skip regression

The fseek* family of functions return 0 on success, not the new offset.
This is only true for lseek.

Fixes https://github.com/libarchive/libarchive/issues/2641
Fixes dcbf1e0ededa95849f098d154a25876ed5754bcf

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2640 from robUx4/xml-uuid
Tim Kientzle [Mon, 26 May 2025 16:06:47 +0000 (09:06 -0700)] 
Merge pull request #2640 from robUx4/xml-uuid

[cmake] add uuid library when using xmllite

2 months ago[cmake] add uuid library when using xmllite 2640/head
Steve Lhomme [Mon, 26 May 2025 08:44:49 +0000 (10:44 +0200)] 
[cmake] add uuid library when using xmllite

Consecutive to 16fd043f51d911b106f2a7834ad8f08f65051977
IID_ISequentialStream is required by the code.
This GUID is defined in uuid.lib or libuuid.a in mingw-w64. It is required
to link with that library to get the definition of the GUID. Some toolchains
add it by default but not all.

2 months agoMerge pull request #2637 from stoeckmann/pax_nl
Tim Kientzle [Sun, 25 May 2025 23:22:59 +0000 (16:22 -0700)] 
Merge pull request #2637 from stoeckmann/pax_nl

tar: Keep block alignment after pax error

2 months agoMerge pull request #2639 from stoeckmann/sprintf_ll
Tim Kientzle [Sun, 25 May 2025 23:19:38 +0000 (16:19 -0700)] 
Merge pull request #2639 from stoeckmann/sprintf_ll

Add ll length modifier to archive_string_vsprintf

2 months agoAdd ll length modifier to archive_string_vsprintf 2639/head
Tobias Stoeckmann [Sun, 25 May 2025 12:26:25 +0000 (14:26 +0200)] 
Add ll length modifier to archive_string_vsprintf

Some error messages already use the ll length modifier, which results
in raw formatter output, i.e. "%lld" instead of a number.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Keep block alignment after pax error 2637/head
Tobias Stoeckmann [Sun, 25 May 2025 10:03:55 +0000 (12:03 +0200)] 
tar: Keep block alignment after pax error

If a pax attribute has a 0 length value and no newline, the tar reader
gets out of sync with block alignment.

This happens because the pax parser assumes that variable value_length
(which includes the terminating newline) is at least 1. To get the
real value length, 1 is subtracted. This result is subtracted from
extsize, which in this case would lead to `extsize -= -1`, i.e.
the remaining byte count is increased.

Such an unexpected calculation leads to an off-by-one when skipping
to the next block. In supplied test case, bsdtar complains that the
checksum of the next block is wrong. Since the tar parser was not
properly 512 bytes aligned, this is no surprise.

Gracefully handle such a case like GNU tar does and warn the user that
an invalid attribute has been encountered.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2636 from zhaofengli/reset-header-state-after-mac-metadata
Tim Kientzle [Sun, 25 May 2025 00:18:00 +0000 (17:18 -0700)] 
Merge pull request #2636 from zhaofengli/reset-header-state-after-mac-metadata

tar: Reset accumulated header state after reading macOS metadata blob

2 months agoAdd test for macOS metadata reading in tar archives 2636/head
Zhaofeng Li [Sat, 24 May 2025 22:40:08 +0000 (16:40 -0600)] 
Add test for macOS metadata reading in tar archives

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2 months agotar: Reset accumulated header state after reading macOS metadata blob
Zhaofeng Li [Sat, 24 May 2025 19:45:18 +0000 (13:45 -0600)] 
tar: Reset accumulated header state after reading macOS metadata blob

AppleDouble extension entries are present as separate files immediately
preceding the corresponding real files. In libarchive, we process the
entire metadata file (headers + data) as if it were a header in the real
file. However, the code forgets to reset the accumulated header state
before parsing the real file's headers. In one code path, this causes
the metadata file's name to be used as the real file's name.

Specifically, this can be triggered with a tar containing two files:

1. A file named `._badname` with pax header containing the `path` attribute
2. A file named `goodname` _with_ a pax header but _without_ the `path` attribute

libarchive will list one file, `._badname` containing the data of `goodname`.

This code is pretty brittle and we really should let the client deal with
it :(

Fixes #2510.

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2 months agoMerge pull request #2630 from stoeckmann/wincrypt_casts
Tim Kientzle [Sat, 24 May 2025 17:45:57 +0000 (10:45 -0700)] 
Merge pull request #2630 from stoeckmann/wincrypt_casts

Fix archive_wincrypt_version

2 months agoMerge pull request #2633 from stoeckmann/match_cleanup
Tim Kientzle [Sat, 24 May 2025 17:37:02 +0000 (10:37 -0700)] 
Merge pull request #2633 from stoeckmann/match_cleanup

archive_match: Simplify and clean up code

2 months agotar: Support negative time values with pax 2634/head
Tobias Stoeckmann [Sat, 24 May 2025 12:47:20 +0000 (14:47 +0200)] 
tar: Support negative time values with pax

Pax extended headers may specify negative time values for files older
than the epoch.

Adjust the code to clear values to 0.0 more often and set ps to
INT64_MIN to have a proper error specifier, because the parser does
not allow anything below -INT64_MAX.

Fixes https://github.com/libarchive/libarchive/issues/2562

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2632 from stoeckmann/cygwin_definition
Tim Kientzle [Sat, 24 May 2025 17:23:28 +0000 (10:23 -0700)] 
Merge pull request #2632 from stoeckmann/cygwin_definition

Prefer __CYGWIN__ over CYGWIN definition

2 months agoarchive_match: Fix whitespaces, style 2633/head
Tobias Stoeckmann [Sat, 24 May 2025 10:35:36 +0000 (12:35 +0200)] 
archive_match: Fix whitespaces, style

Adjust whitespaces to match file layout and add a full stop to
a comment to match others.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_match: Use correct data type for iterator
Tobias Stoeckmann [Sat, 24 May 2025 10:29:36 +0000 (12:29 +0200)] 
archive_match: Use correct data type for iterator

Iterating over a size_t with unsigned could lead to an endless loop
while adding uid/gid to a list which already counts 4 billion
entries.

I doubt that this can ever happen, given that the routines become
very slow with insertions, but better be safe than sorry.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_match: Allow arbitrarily long match lists
Tobias Stoeckmann [Sat, 24 May 2025 10:28:08 +0000 (12:28 +0200)] 
archive_match: Allow arbitrarily long match lists

Turn unmatched_count into a size_t to support as many entries as
possible on the machine.

If more than INT_MAX entries are not matched, truncate the result
of archive_match_path_unmatched_inclusions for external callers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_match: Remove unneeded count fields
Tobias Stoeckmann [Sat, 24 May 2025 10:24:49 +0000 (12:24 +0200)] 
archive_match: Remove unneeded count fields

The count fields are merely used to check if a list is empty or not.
A check for first being not NULL is sufficient and is already in
place while iterating over the linked elements (count is not used).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_match: Set red/black tree operations once
Tobias Stoeckmann [Sat, 24 May 2025 10:07:04 +0000 (12:07 +0200)] 
archive_match: Set red/black tree operations once

The operations for key and node comparison depend on the platform
libarchive is compiled for. Since these values do not change
during runtime, set them only once during initialisation.

Further simplify the code by declaring only one "rb_ops" with
required functions based on platform.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoPrefer __CYGWIN__ over CYGWIN definition 2632/head
Tobias Stoeckmann [Sat, 24 May 2025 09:37:26 +0000 (11:37 +0200)] 
Prefer __CYGWIN__ over CYGWIN definition

The cygwin FAQ states that __CYGWIN__ is defined when building for a
Cygwin environment. Only a few test files check (inconsistently) for
CYGWIN, so adjust them to the recommended __CYGWIN__ definition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2631 from stoeckmann/configure_windows
Tim Kientzle [Sat, 24 May 2025 02:58:02 +0000 (19:58 -0700)] 
Merge pull request #2631 from stoeckmann/configure_windows

configure.ac: Improve Windows version detection

2 months agoMerge pull request #2509 from tesap/install-lib-dir
Tim Kientzle [Sat, 24 May 2025 02:57:14 +0000 (19:57 -0700)] 
Merge pull request #2509 from tesap/install-lib-dir

Make installation lib dir depend on CMAKE_INSTALL_LIBDIR variable

2 months agoMerge pull request #2629 from mmatuska/fix/versiontest
Tim Kientzle [Sat, 24 May 2025 02:39:00 +0000 (19:39 -0700)] 
Merge pull request #2629 from mmatuska/fix/versiontest

tests: accept underscore in arbitrary third-party version strings

2 months agoSet ARCHIVE_CRYPTOR_USE_WINCRYPT for WinCrypt 2630/head
Tobias Stoeckmann [Fri, 23 May 2025 17:33:53 +0000 (19:33 +0200)] 
Set ARCHIVE_CRYPTOR_USE_WINCRYPT for WinCrypt

If WinCrypt is used, actually set ARCHIVE_CRYPTOR_USE_WINCRYPT
for version details output.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_version_details.c: Drop ARCHIVE_DIGEST_*
Tobias Stoeckmann [Fri, 23 May 2025 17:27:08 +0000 (19:27 +0200)] 
archive_version_details.c: Drop ARCHIVE_DIGEST_*

These definitions are never available and are supposedly a leftover of
a work in progress.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoconfigure.ac: Improve Windows version detection 2631/head
Tobias Stoeckmann [Fri, 23 May 2025 17:22:06 +0000 (19:22 +0200)] 
configure.ac: Improve Windows version detection

Include windows.h for better windows version detection.

Fixes https://github.com/libarchive/libarchive/issues/2628

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoFix archive_wincrypt_version compilation
Tobias Stoeckmann [Fri, 23 May 2025 16:59:05 +0000 (18:59 +0200)] 
Fix archive_wincrypt_version compilation

Cast address of "version" to BYTE pointer for CryptGetProvParam.
Fix "major" variable assignment for picky compilers like MSVC.

The "length" variable is an in/out variable. It must be set to the size
of available memory within "version". Right now it is undefined behavior
and 0 would crash during runtime.

Fixes https://github.com/libarchive/libarchive/issues/2628

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotests: accept underscore in arbitrary third-party version strings 2629/head
Martin Matuska [Fri, 23 May 2025 11:19:21 +0000 (13:19 +0200)] 
tests: accept underscore in arbitrary third-party version strings

Fixes #2626

2 months agoUse PKG_CONFIG instead of hard-coded pkg-config 2627/head
Heiko Becker [Tue, 20 May 2025 22:44:50 +0000 (00:44 +0200)] 
Use PKG_CONFIG instead of hard-coded pkg-config

2 months agoMerge pull request #2624 from mmatuska/feat/390dev
Tim Kientzle [Tue, 20 May 2025 14:55:26 +0000 (07:55 -0700)] 
Merge pull request #2624 from mmatuska/feat/390dev

Libarchive 3.9.0dev

2 months agoLibarchive 3.9.0dev 2624/head
Martin Matuska [Tue, 20 May 2025 08:26:29 +0000 (10:26 +0200)] 
Libarchive 3.9.0dev

2 months agoCI: Bump the all-actions group across 1 directory with 4 updates (#2623)
dependabot[bot] [Tue, 20 May 2025 08:19:56 +0000 (10:19 +0200)] 
CI: Bump the all-actions group across 1 directory with 4 updates (#2623)

Bumps the all-actions group with 4 updates:
`actions/checkout` from 4.2.1 to 4.2.2
`actions/upload-artifact` from 4.4.3 to 4.6.2
`github/codeql-action` from 3.26.12 to 3.28.18
`ossf/scorecard-action` from 2.4.0 to 2.4.1

2 months agoAdd some more error checking to shell scripts (#2617)
Mostyn Bramley-Moore [Tue, 20 May 2025 08:14:17 +0000 (10:14 +0200)] 
Add some more error checking to shell scripts (#2617)

Exit immediately if a command exits with a non-zero status, and treat
unset variables as an error when substituting.

2 months agoMerge pull request #2612 from AZero13/okay-what
Tim Kientzle [Tue, 20 May 2025 02:39:10 +0000 (19:39 -0700)] 
Merge pull request #2612 from AZero13/okay-what

Fatal if field[0].start is null

2 months agoMerge pull request #2622 from AZero13/calculate-size
Tim Kientzle [Tue, 20 May 2025 02:38:04 +0000 (19:38 -0700)] 
Merge pull request #2622 from AZero13/calculate-size

Calculate size of arrays instead of assuming they are always 6

2 months agoMerge pull request #2621 from AZero13/redundant-s
Tim Kientzle [Tue, 20 May 2025 02:36:57 +0000 (19:36 -0700)] 
Merge pull request #2621 from AZero13/redundant-s

*s != '\0' is redundant

2 months agoMerge pull request #2619 from AZero13/patch-2
Tim Kientzle [Tue, 20 May 2025 02:34:24 +0000 (19:34 -0700)] 
Merge pull request #2619 from AZero13/patch-2

days should be a long type

2 months agoMerge pull request #2618 from AZero13/patch-1
Tim Kientzle [Tue, 20 May 2025 02:32:32 +0000 (19:32 -0700)] 
Merge pull request #2618 from AZero13/patch-1

Label error and errorx as __LA_NORETURN

2 months agoCalculate size of arrays instead of assuming they are always 6 2622/head
Rose [Mon, 19 May 2025 19:19:57 +0000 (15:19 -0400)] 
Calculate size of arrays instead of assuming they are always 6

2 months ago*s != '\0' is redundant 2621/head
Rose [Mon, 19 May 2025 19:16:18 +0000 (15:16 -0400)] 
*s != '\0' is redundant

Not that this does anything to codegen probably, but it is still redundant.

2 months agoFatal if field[0].start or field[0].end is null 2612/head
Rose [Sat, 17 May 2025 23:35:22 +0000 (19:35 -0400)] 
Fatal if field[0].start or field[0].end is null

We should not get here, but given that the check exists, we should not let it happen if this is NULL because otherwise we just dereference it later on.

2 months agodays should be a long type 2619/head
AZero13 [Mon, 19 May 2025 17:39:32 +0000 (13:39 -0400)] 
days should be a long type

The difference in years is cast to a long and then multiplied by 365. The return value of the function is also a long.

2 months agoLabel error and errorx as __LA_NORETURN 2618/head
AZero13 [Mon, 19 May 2025 17:35:19 +0000 (13:35 -0400)] 
Label error and errorx as __LA_NORETURN

This also prevents clang-tidy from reporting some false bugs.

2 months agoMerge pull request #2611 from zhaofengli/fix-iconv-pc
Tim Kientzle [Sun, 18 May 2025 22:44:48 +0000 (15:44 -0700)] 
Merge pull request #2611 from zhaofengli/fix-iconv-pc

autotools: Fix iconv issues in generated .pc file

2 months agoMerge pull request #2613 from mmatuska/fix/7zipsfx-2
Tim Kientzle [Sun, 18 May 2025 22:41:26 +0000 (15:41 -0700)] 
Merge pull request #2613 from mmatuska/fix/7zipsfx-2

7z: fix another out-of-bounds read in 7z SFX archive detection

2 months agoMerge pull request #2616 from mostynb/contrib_psota-benchmark_tcp_sh_bash
Tim Kientzle [Sun, 18 May 2025 22:26:17 +0000 (15:26 -0700)] 
Merge pull request #2616 from mostynb/contrib_psota-benchmark_tcp_sh_bash

contrib/psota-benchmark/tcp.sh is a bash script

2 months agoMerge pull request #2614 from AZero13/tar-2
Tim Kientzle [Sun, 18 May 2025 22:25:11 +0000 (15:25 -0700)] 
Merge pull request #2614 from AZero13/tar-2

Assign a result when failure happens

2 months agoMerge pull request #2600 from nvinson/master
Tim Kientzle [Sun, 18 May 2025 21:59:36 +0000 (14:59 -0700)] 
Merge pull request #2600 from nvinson/master

Copy ae digests to mtree_entry

2 months agoRemove long-unused travis CI script (#2615)
Mostyn Bramley-Moore [Sun, 18 May 2025 16:55:32 +0000 (18:55 +0200)] 
Remove long-unused travis CI script (#2615)

Support for travis CI was removed in 2019, this script hasn't been used
since.

2 months agocontrib/psota-benchmark/tcp.sh is a bash script 2616/head
Mostyn Bramley-Moore [Sun, 18 May 2025 10:58:27 +0000 (12:58 +0200)] 
contrib/psota-benchmark/tcp.sh is a bash script

I am unsure if this is still used, but it fails to run in Bourne shell.

2 months agoAssign a result when failure happens 2614/head
Rose [Sun, 18 May 2025 01:24:51 +0000 (21:24 -0400)] 
Assign a result when failure happens

In some places, result is checked even after failure, so let's assign a result.

2 months ago7z: fix another out-of-bounds read in 7z SFX archive detection 2613/head
Martin Matuska [Sun, 18 May 2025 00:40:05 +0000 (02:40 +0200)] 
7z: fix another out-of-bounds read in 7z SFX archive detection

When looping over program header entries (e_shnum)
we need to increment sec_tbl_offset by e_shentsize
and not by fixed values.

Fixes OSS-Fuzz issue 418349489

2 months agoMerge pull request #2610 from stoeckmann/string_int_size_t
Tim Kientzle [Sun, 18 May 2025 00:15:03 +0000 (17:15 -0700)] 
Merge pull request #2610 from stoeckmann/string_int_size_t

archive_string: Check values before casts

2 months agoautotools: Fix iconv issues in generated .pc file 2611/head
Zhaofeng Li [Sat, 17 May 2025 00:03:52 +0000 (18:03 -0600)] 
autotools: Fix iconv issues in generated .pc file

The goal is to make everyone (including msys2) happy.

Fixes #1766 and #1819.

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
2 months agoMerge pull request #2609 from stoeckmann/safe_fprintf
Tim Kientzle [Sat, 17 May 2025 18:46:32 +0000 (11:46 -0700)] 
Merge pull request #2609 from stoeckmann/safe_fprintf

tar: Handle more edge cases in safe_fprintf

2 months agotest_utils/test_main.c: increase logfilename bf sz 2600/head
Nicholas Vinson [Sat, 17 May 2025 15:30:23 +0000 (11:30 -0400)] 
test_utils/test_main.c: increase logfilename bf sz

Increase logfilename buffer size from 64 to 256. This aligns the buffer
size with the size limits found in Windows and Linux.

2 months agoReplace struct ae_mset_digest with uint_least32_t
Nicholas Vinson [Tue, 13 May 2025 23:38:50 +0000 (19:38 -0400)] 
Replace struct ae_mset_digest with uint_least32_t

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
2 months agoCopy ae digests to mtree_entry
Nicholas Vinson [Sun, 13 Apr 2025 11:33:43 +0000 (07:33 -0400)] 
Copy ae digests to mtree_entry

    Copy ae digests to mtree_entry. This simplifies porting non-archive
    formats to archive formats while preserving supported message
    digests specifically in cases where recomputing digests is not
    viable.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
2 months agoarchive_string: Check values before casts 2610/head
Tobias Stoeckmann [Sat, 17 May 2025 08:36:47 +0000 (10:36 +0200)] 
archive_string: Check values before casts

The size_t to int conversion is especially required on Windows systems
to support their int-based functions. These variables should be properly
checked before casts. This avoids integer truncations with large
strings.

I prefer size_t over int for sizes and adjusted variables to size_t
where possible to avoid casts.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoMerge pull request #2604 from mmatuska/fix/7zipsfx
Tim Kientzle [Fri, 16 May 2025 23:40:24 +0000 (16:40 -0700)] 
Merge pull request #2604 from mmatuska/fix/7zipsfx

7z: fix out-of-bounds read in 7z self extracting archive detection

2 months agoMerge pull request #2607 from zhaofengli/disallow-multiple-files-from
Tim Kientzle [Fri, 16 May 2025 22:49:16 +0000 (15:49 -0700)] 
Merge pull request #2607 from zhaofengli/disallow-multiple-files-from

bsdtar: Disallow multiple --files-from/-T options

2 months agotar: Make safe_fprintf more platform independent 2609/head
Tobias Stoeckmann [Fri, 16 May 2025 22:01:53 +0000 (00:01 +0200)] 
tar: Make safe_fprintf more platform independent

If vsnprintf fails with errno EOVERFLOW, the results are very platform
dependent but never useful. The implementation in glibc fills bytes with
blanks, FreeBSD fills them with zeros, OpenBSD and Windows set first
byte to '\0'.

Just stop processing and don't print anything, which makes it follow
the OpenBSD and Windows approach.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Fix safe_fprintf comment
Tobias Stoeckmann [Fri, 16 May 2025 21:25:42 +0000 (23:25 +0200)] 
tar: Fix safe_fprintf comment

The stack buffer is never used for out of memory messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Support large strings in safe_fprintf
Tobias Stoeckmann [Fri, 16 May 2025 21:11:52 +0000 (23:11 +0200)] 
tar: Support large strings in safe_fprintf

The vsnprintf calls might return INT_MAX with very long strings.
Prevent a signed integer overflow when taking an additional nul
byte into account.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Always use correct length in safe_fprintf
Tobias Stoeckmann [Fri, 16 May 2025 21:08:59 +0000 (23:08 +0200)] 
tar: Always use correct length in safe_fprintf

If the format buffer shall not be further increased in size, the
length value mistakenly takes the terminating nul byte into account.

This is in contrast to a successful vsnprintf call.

Also use the correct string length if fallback to stack buffer is
required.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Clear safe_fprintf stack before usage
Tobias Stoeckmann [Fri, 16 May 2025 21:50:27 +0000 (23:50 +0200)] 
tar: Clear safe_fprintf stack before usage

The stack buffer is never cleared, which can become an issue depending
on vsnprintf implementation's behavior if -1 is returned. The code
would eventually fall back to stack buffer which might be not
nul terminated.

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