]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
43 hours agoMerge pull request #2740 from dunhor/gnutar_longpath_unicode master
Tim Kientzle [Sat, 4 Oct 2025 03:43:21 +0000 (20:43 -0700)] 
Merge pull request #2740 from dunhor/gnutar_longpath_unicode

Check WCS pathname in header_gnutar before overwriting

8 days agoMerge pull request #2729 from KlaraSystems/des/leak-on-fatal
Tim Kientzle [Sat, 27 Sep 2025 17:25:03 +0000 (10:25 -0700)] 
Merge pull request #2729 from KlaraSystems/des/leak-on-fatal

Don't leak memory on fatal error

8 days agoMerge pull request #2742 from bradking/parse-date-2038
Tim Kientzle [Sat, 27 Sep 2025 02:52:20 +0000 (19:52 -0700)] 
Merge pull request #2742 from bradking/parse-date-2038

parse_date: handle dates in 2038 and beyond if time_t is big enough

8 days agoMerge pull request #2741 from e-kwsm/extra-semi
Tim Kientzle [Sat, 27 Sep 2025 02:50:52 +0000 (19:50 -0700)] 
Merge pull request #2741 from e-kwsm/extra-semi

fix: remove extra ';' outside of functions

9 days agoparse_date: handle dates in 2038 and beyond if time_t is big enough 2742/head
Brad King [Fri, 26 Sep 2025 21:08:00 +0000 (17:08 -0400)] 
parse_date: handle dates in 2038 and beyond if time_t is big enough

9 days agofix: remove extra ';' outside of functions 2741/head
Eisuke Kawashima [Fri, 26 Sep 2025 10:38:01 +0000 (19:38 +0900)] 
fix: remove extra ';' outside of functions

10 days agoCheck WCS pathname in header_gnutar 2740/head
Duncan Horn [Thu, 25 Sep 2025 23:03:18 +0000 (16:03 -0700)] 
Check WCS pathname in header_gnutar

11 days agoMerge pull request #2739 from DHowett/remove-wincrypt
Tim Kientzle [Wed, 24 Sep 2025 13:21:23 +0000 (06:21 -0700)] 
Merge pull request #2739 from DHowett/remove-wincrypt

windows: remove support for WinCrypt

13 days agoWIP: remove WinCrypt support 2739/head
Dustin L. Howett [Sun, 27 Jul 2025 00:17:28 +0000 (19:17 -0500)] 
WIP: remove WinCrypt support

I am debating whether to remove the checks for bcrypt as well (it is
supported on all versions of Windows currently targeted.)

fixes https://github.com/libarchive/libarchive/issues/2595

3 weeks agoMerge pull request #2734 from kientzle/kientzle-ignore-too-long-gzip-filename
Tim Kientzle [Sun, 14 Sep 2025 02:34:03 +0000 (19:34 -0700)] 
Merge pull request #2734 from kientzle/kientzle-ignore-too-long-gzip-filename

Ignore over-long gzip filename

3 weeks agoFix the reference to the archive object 2734/head
Tim Kientzle [Sat, 13 Sep 2025 20:07:33 +0000 (13:07 -0700)] 
Fix the reference to the archive object

3 weeks agoMerge pull request #2735 from kientzle/kientzle-err.h-conflict
Martin Matuška [Sat, 13 Sep 2025 20:01:52 +0000 (22:01 +0200)] 
Merge pull request #2735 from kientzle/kientzle-err.h-conflict

Rename err.h to avoid conflict with system header

3 weeks agoMerge pull request #2731 from mmatuska/fix/macosci
Martin Matuška [Sat, 13 Sep 2025 19:36:29 +0000 (21:36 +0200)] 
Merge pull request #2731 from mmatuska/fix/macosci

CI: add workaround for cmake installed from local/pinned tab on GH/MacOS

3 weeks agoMerge pull request #2732 from mmatuska/fix/safe-dir-over-reg-win
Martin Matuška [Sat, 13 Sep 2025 19:36:13 +0000 (21:36 +0200)] 
Merge pull request #2732 from mmatuska/fix/safe-dir-over-reg-win

win: add complementary safe writes fix for Windows to 27588eba5 (#2477)

3 weeks agoRename err.h to avoid conflict with system header 2735/head
Tim Kientzle [Sat, 13 Sep 2025 19:30:03 +0000 (12:30 -0700)] 
Rename err.h to avoid conflict with system header

Depending on header search path ordering, we can easily
confuse libarchive_fe/err.h with the system header.
Rename ours to lafe_err.h to avoid the confusion.
Rename libarchive_fe/err.c to match.

3 weeks agoOnly set the filename-present bit if we actually write the filename
Tim Kientzle [Sat, 13 Sep 2025 18:17:38 +0000 (11:17 -0700)] 
Only set the filename-present bit if we actually write the filename

3 weeks agoFix some nearby formatting
Tim Kientzle [Fri, 12 Sep 2025 16:03:01 +0000 (09:03 -0700)] 
Fix some nearby formatting

3 weeks agoIgnore overlong gzip original_filename
Tim Kientzle [Fri, 12 Sep 2025 16:01:13 +0000 (09:01 -0700)] 
Ignore overlong gzip original_filename

We reuse the compression buffer to format the gzip header,
but didn't check for an overlong gzip original_filename.
This adds that check.  If the original_filename is
over 32k (or bigger than the buffer in case someone shrinks
the buffer someday), we WARN and ignore the filename.

3 weeks agowin: add complementary safe writes fix for Windows to 27588eba5 (#2477) 2732/head
Martin Matuska [Wed, 10 Sep 2025 08:57:55 +0000 (10:57 +0200)] 
win: add complementary safe writes fix for Windows to 27588eba5 (#2477)

3 weeks agoCI: add workaround for cmake installed from local/pinned tab on GH/MacOS 2731/head
Martin Matuska [Wed, 10 Sep 2025 08:50:46 +0000 (10:50 +0200)] 
CI: add workaround for cmake installed from local/pinned tab on GH/MacOS

3 weeks agoMerge pull request #2670 from benoit-pierre/pr/fix_zip_writing_with_zstd_compression_...
Martin Matuška [Wed, 10 Sep 2025 08:41:33 +0000 (10:41 +0200)] 
Merge pull request #2670 from benoit-pierre/pr/fix_zip_writing_with_zstd_compression_method

zip: fix writing with ZSTD compression

3 weeks agoMerge pull request #2477 from jrtc27/safe-dir-over-reg
Martin Matuška [Wed, 10 Sep 2025 08:40:44 +0000 (10:40 +0200)] 
Merge pull request #2477 from jrtc27/safe-dir-over-reg

Fix replacing a regular file with a dir for ARCHIVE_EXTRACT_SAFE_WRITES

3 weeks agoMerge pull request #2686 from stoeckmann/lseek_win_regression
Martin Matuška [Wed, 10 Sep 2025 08:24:34 +0000 (10:24 +0200)] 
Merge pull request #2686 from stoeckmann/lseek_win_regression

Fix Windows off_t handling

3 weeks agoMerge pull request #2710 from meecash/CVE-2025-25724-check_strftime_result
Martin Matuška [Wed, 10 Sep 2025 08:22:58 +0000 (10:22 +0200)] 
Merge pull request #2710 from meecash/CVE-2025-25724-check_strftime_result

Fix CVE-2025-25724 by checking the result of the strftime

3 weeks agoarchive_write: Set archive state to fatal if format or filters fail 2729/head
Dag-Erling Smørgrav [Mon, 8 Sep 2025 20:17:09 +0000 (22:17 +0200)] 
archive_write: Set archive state to fatal if format or filters fail

In archive_write_header(), if the format method or a filter flush method
fails, we set the archive state to fatal, but we did not do this in
archive_write_data() or archive_write_finish_entry().  There is no good
reason for this discrepancy.  Not setting the archive state to fatal
means a subsequent archive_write_free() will invoke archive_write_close()
which may retry the operation and cause archive_write_free() to return
an unexpected ARCHIVE_FATAL.

3 weeks agowrite_add_filter_bzip2: End compression in the freer
Dag-Erling Smørgrav [Mon, 8 Sep 2025 19:20:32 +0000 (21:20 +0200)] 
write_add_filter_bzip2: End compression in the freer

If a fatal error occurs, the closer will not be called, so neither will
BZ2_bzCompressEnd(), and we will leak memory.  Fix this by calling it a
second time from the freer.  This is harmless in the non-error case as
it will see that the compression state has already been cleared and
immediately return BZ_PARAM_ERROR, which we simply ignore.

3 weeks agoarchive_write_client: Free state in freer, not in closer
Dag-Erling Smørgrav [Mon, 8 Sep 2025 19:14:04 +0000 (21:14 +0200)] 
archive_write_client: Free state in freer, not in closer

The closer will not be called if a fatal error occurs, so the current
arrangement results in a memory leak.  The downside is that the freer
may be called even if we were not fully constructed, so it needs to
perform additional checks.  On the other hand, knowing that the freer
always gets called and will free the client state simplifies error
handling in the opener.

6 weeks agoMerge pull request #2717 from peakschris/cb_windows
Tim Kientzle [Fri, 22 Aug 2025 15:13:40 +0000 (08:13 -0700)] 
Merge pull request #2717 from peakschris/cb_windows

bsdtar: Allow @filename to have CRLF endings

6 weeks agoaddress review comment 2717/head
Chris Brown [Fri, 22 Aug 2025 08:00:44 +0000 (04:00 -0400)] 
address review comment

6 weeks agoMerge pull request #2707 from fdegros/close_range_support
Tim Kientzle [Wed, 20 Aug 2025 18:18:45 +0000 (11:18 -0700)] 
Merge pull request #2707 from fdegros/close_range_support

Avoid leaking file descriptors into subprocesses

6 weeks agoUse sysconf(_SC_OPEN_MAX) on systems without close_range or closefrom 2707/head
François Degros [Wed, 20 Aug 2025 05:45:32 +0000 (15:45 +1000)] 
Use sysconf(_SC_OPEN_MAX) on systems without close_range or closefrom

Close all the file descriptors in the range [3 ..
sysconf(_SC_OPEN_MAX)-1] before executing a filter program to avoid
leaking file descriptors into subprocesses.

Bug: https://github.com/libarchive/libarchive/issues/2520

7 weeks agoMerge pull request #2696 from al3xtjames/mkstemp
Tim Kientzle [Sat, 16 Aug 2025 16:27:11 +0000 (10:27 -0600)] 
Merge pull request #2696 from al3xtjames/mkstemp

Fix mkstemp path in setup_mac_metadata

7 weeks agoMerge pull request #2723 from KlaraSystems/des/couldnt-visit
Martin Matuška [Thu, 14 Aug 2025 21:22:30 +0000 (23:22 +0200)] 
Merge pull request #2723 from KlaraSystems/des/couldnt-visit

archive_read_disk_posix: Don't pass -1 to a function expecting errno

7 weeks agoMerge pull request #2716 from antekone/bug/GH-2714/infinite-loop/1
Martin Matuška [Thu, 14 Aug 2025 21:20:55 +0000 (23:20 +0200)] 
Merge pull request #2716 from antekone/bug/GH-2714/infinite-loop/1

RAR5 reader: early fail when file declares data for a dir entry

7 weeks agoMerge pull request #2713 from antekone/bug/GH-2711/crash-when-rr/1
Martin Matuška [Thu, 14 Aug 2025 21:20:01 +0000 (23:20 +0200)] 
Merge pull request #2713 from antekone/bug/GH-2711/crash-when-rr/1

RAR5 reader: fix multiple issues in extra field parsing function

7 weeks agoMerge pull request #2700 from mostynb/avoid_libxml2_deprecation_warnings
Martin Matuška [Thu, 14 Aug 2025 21:17:39 +0000 (23:17 +0200)] 
Merge pull request #2700 from mostynb/avoid_libxml2_deprecation_warnings

xar: avoid libxml2 deprecation warnings

7 weeks agoarchive_read_disk_posix: Don't pass -1 to a function expecting errno 2723/head
Dag-Erling Smørgrav [Thu, 14 Aug 2025 12:36:11 +0000 (14:36 +0200)] 
archive_read_disk_posix: Don't pass -1 to a function expecting errno

This fixes an unhelpful "Couldn't visit directory: Unknown error: -1" message.

Fixes: 3311bb52cbe4 ("Bring the code supporting directory traversals from bsdtar/tree.[ch] into archive_read_disk.c and modify it. Introduce new APIs archive_read_disk_open and archive_read_disk_descend.")

8 weeks agorevert test verbosity change
Chris Brown [Sat, 9 Aug 2025 20:43:55 +0000 (16:43 -0400)] 
revert test verbosity change

8 weeks agorevert ci fix which didn't help
Chris Brown [Sat, 9 Aug 2025 20:13:26 +0000 (16:13 -0400)] 
revert ci fix which didn't help

8 weeks agodisable tests on windows; they don't work
Chris Brown [Sat, 9 Aug 2025 19:51:48 +0000 (15:51 -0400)] 
disable tests on windows; they don't work

8 weeks agofix test
Chris Brown [Sat, 9 Aug 2025 19:50:45 +0000 (15:50 -0400)] 
fix test

8 weeks agofix mingw windows build issue
Chris Brown [Sat, 9 Aug 2025 19:32:55 +0000 (15:32 -0400)] 
fix mingw windows build issue

8 weeks agoincrease test verbosity
Chris Brown [Sat, 9 Aug 2025 19:28:34 +0000 (15:28 -0400)] 
increase test verbosity

8 weeks agoenable tests on windows
Chris Brown [Sat, 9 Aug 2025 19:08:49 +0000 (15:08 -0400)] 
enable tests on windows

8 weeks agoupdate autotools
Chris Brown [Sat, 9 Aug 2025 00:53:33 +0000 (20:53 -0400)] 
update autotools

8 weeks agoupdate test
Chris Brown [Sat, 9 Aug 2025 00:40:14 +0000 (20:40 -0400)] 
update test

8 weeks agoadd test
Chris Brown [Sat, 9 Aug 2025 00:15:35 +0000 (20:15 -0400)] 
add test

8 weeks agosuggested changes by kientzle
Chris Brown [Fri, 8 Aug 2025 23:41:51 +0000 (19:41 -0400)] 
suggested changes by kientzle

8 weeks agodebug non-printing characters and handle CRLF
Chris Brown [Fri, 8 Aug 2025 15:56:39 +0000 (11:56 -0400)] 
debug non-printing characters and handle CRLF

2 months agoRAR5 reader: early fail when file declares data for a dir entry 2716/head
Grzegorz Antoniak [Mon, 4 Aug 2025 13:07:32 +0000 (15:07 +0200)] 
RAR5 reader: early fail when file declares data for a dir entry

RAR5 reader had inconsistent sanity checks for directory entries that
declare data. On one hand such declaration was accepted during the
header parsing process, but at the same time this was disallowed during
the data reading process. Disallow logic was returning the
ARCHIVE_FAILED error code that allowed the client to retry, while in
reality, the error was non-retryable.

This commit adds another sanity check during the header parsing logic
that disallows the directory entries to declare any data. This will make
clients fail early when such entry is detected.

Also, the commit changes the ARCHIVE_FAILED error code to ARCHIVE_FATAL
when trying to read data for the directory entry that declares data.
This makes sure that tools like bsdtar won't attempt to retry unpacking
such data.

Fixes issue #2714.

2 months agoRAR5 reader: fix multiple issues in extra field parsing function 2713/head
Grzegorz Antoniak [Fri, 1 Aug 2025 20:02:30 +0000 (22:02 +0200)] 
RAR5 reader: fix multiple issues in extra field parsing function

This commit fixes multiple issues found in the function that parses
extra fields found in the "file"/"service" blocks.

1. In case the file declares just one extra field, which is an
   unsupported field, the function returns ARCHIVE_FATAL.

   The commit fixes this so this case is allowed, and the unsupported
   extra field is skipped. The commit also introduces a test for this
   case.

2. Current parsing method of extra fields can report parsing errors in
   case the file is malformed. The problem is that next iteration of
   parsing, which is meant to process the next extra field (if any),
   overwrites the result of the previous iteration, even if previous
   iteration has reported parsing error. A successful parse can be
   returned in this case, leading to undefined behavior.

   This commit changes the behavior to fail the parsing function early.
   Also a test file is introduced for this case.

3. In case the file declares only the EX_CRYPT extra field, current
   function simply returns ARCHIVE_FATAL, preventing the caller from
   setting the proper error string. This results in libarchive returning
   an ARCHIVE_FATAL without any error messages set. The PR #2096 (commit
   adee36b00) was specifically created to provide error strings in case
   EX_CRYPT attribute was encountered, but current behavior contradicts
   this case.

   The commit changes the behavior so that ARCHIVE_OK is returned by the
   extra field parsing function in only EX_CRYPT is encountered, so that
   the caller header reading function can properly return ARCHIVE_FATAL
   to the caller, at the same time setting a proper error string. A test
   file is also provided for this case.

This PR should fix issue #2711.

2 months agoMerge pull request #2712 from KlaraSystems/des/readdir_r
Tim Kientzle [Sat, 2 Aug 2025 23:33:01 +0000 (16:33 -0700)] 
Merge pull request #2712 from KlaraSystems/des/readdir_r

Drop support for readdir_r()

2 months agoDrop support for readdir_r() 2712/head
Dag-Erling Smørgrav [Fri, 1 Aug 2025 14:44:36 +0000 (16:44 +0200)] 
Drop support for readdir_r()

There has never been a good reason to prefer it over readdir(), and it
has now been marked obsolete in POSIX-1.2024.

2 months agoUse POSIX_SPAWN_CLOEXEC_DEFAULT when possible
François Degros [Thu, 31 Jul 2025 05:51:26 +0000 (15:51 +1000)] 
Use POSIX_SPAWN_CLOEXEC_DEFAULT when possible

Use posix_spawn() with POSIX_SPAWN_CLOEXEC_DEFAULT on systems that
define this constant, in order to avoid leaking file descriptors into
subprocesses.

Bug: https://github.com/libarchive/libarchive/issues/2520

2 months agoUse closefrom() or close_range() when possible
François Degros [Tue, 29 Jul 2025 05:18:28 +0000 (15:18 +1000)] 
Use closefrom() or close_range() when possible

To avoid leaking file descriptors into subprocesses.

Fixes: https://github.com/libarchive/libarchive/issues/2520
2 months agoFix CVE-2025-25724 by checking the result of the strftime 2710/head
Marcin Mikula [Wed, 30 Jul 2025 08:29:12 +0000 (10:29 +0200)] 
Fix CVE-2025-25724 by checking the result of the strftime
to avoid use of undefined content of buf, in case when custom
locale makes the result string longer than buf length.

Signed-off-by: Marcin Mikula <marcin@helix.pl>
2 months agoMerge pull request #2704 from kientzle/kientzle-harden-append-acl
Tim Kientzle [Sat, 26 Jul 2025 19:24:43 +0000 (12:24 -0700)] 
Merge pull request #2704 from kientzle/kientzle-harden-append-acl

Guard against invalid type arguments

2 months agoGuard against invalid type arguments 2704/head
Tim Kientzle [Sat, 26 Jul 2025 18:10:24 +0000 (11:10 -0700)] 
Guard against invalid type arguments

Some experiments showed strange things happen if you
provide an invalid type value when appending a new ACL entry.
Guard against that, and while we're here be a little more
paranoid elsewhere against bad types in case there is another
way to get them in.

2 months agozip: fix writing with ZSTD compression 2670/head
Benoit Pierre [Sat, 7 Jun 2025 22:30:14 +0000 (00:30 +0200)] 
zip: fix writing with ZSTD compression

When testing the feature with `bsdtar -acf test.zip --options
zip:compression=zstd …` on a tree of ~100MB, the execution would
appear to "hang" while writing a multi-gigabytes ZIP file.

2 months agoMerge pull request #2699 from mostynb/7z_eopm_reference
Tim Kientzle [Fri, 18 Jul 2025 02:18:53 +0000 (19:18 -0700)] 
Merge pull request #2699 from mostynb/7z_eopm_reference

7z: add liblzma EOPM reference

2 months ago7z: add liblzma EOPM reference 2699/head
Mostyn Bramley-Moore [Tue, 15 Jul 2025 20:13:10 +0000 (22:13 +0200)] 
7z: add liblzma EOPM reference

This is useful for developers trying to understand the 7z read support code.

2 months agoxar: avoid libxml2 deprecation warnings 2700/head
Mostyn Bramley-Moore [Tue, 15 Jul 2025 11:18:14 +0000 (13:18 +0200)] 
xar: avoid libxml2 deprecation warnings

2 months agoMerge pull request #2697 from Kraust/topic/cmake_build_fixes
Tim Kientzle [Mon, 14 Jul 2025 17:05:56 +0000 (10:05 -0700)] 
Merge pull request #2697 from Kraust/topic/cmake_build_fixes

Allow Compiling Against Static CRT.

2 months agoAllow Compiling Against Static CRT. 2697/head
Kraust [Mon, 14 Jul 2025 02:57:25 +0000 (22:57 -0400)] 
Allow Compiling Against Static CRT.

2 months agoFix mkstemp path in setup_mac_metadata 2696/head
Alex James [Sat, 12 Jul 2025 20:44:55 +0000 (15:44 -0500)] 
Fix mkstemp path in setup_mac_metadata

setup_mac_metadata currently concates the template after TMPDIR without
adding a path separator, which causes mkstemp to create a temporary file
next to TMPDIR instead of in TMPDIR. Add a path separator to the
template to ensure that the temporary file is created under TMPDIR.

I hit this while rebuilding libarchive in nixpkgs. Lix recently started
using a dedicated build directory (under /nix/var/nix/builds) instead of
using a directory under /tmp [1]. nixpkgs & Lix support (optional)
on macOS sandboxing. The default sandbox profile allows builds to access
paths under the build directory and any path under /tmp. Because the
build directory is no longer under /tmp, some of libarchive's tests
started to fail as they accessed paths next to (but not under) the build
directory:

cpio/test/test_basic.c:65: Contents don't match
   Description: Expected: 2 blocks
, options=
  file="pack.err"
0000_62_73_64_63_70_69_6f_3a_20_43_6f_75_6c_64_20_6e_bsdcpio: Could n
0010_6f_74_20_6f_70_65_6e_20_65_78_74_65_6e_64_65_64_ot open extended
0020_20_61_74_74_72_69_62_75_74_65_20_66_69_6c_65_0a_ attribute file.

Sandbox: bsdcpio(11215) deny(1) file-write-create /nix/var/nix/builds/nix-build-libarchive-3.8.0.drv-7tar.md.5EUrQu

[1]: https://lix.systems/blog/2025-06-24-lix-cves/

2 months agoMerge pull request #2694 from stoeckmann/cleanups
Tim Kientzle [Sat, 12 Jul 2025 04:06:20 +0000 (21:06 -0700)] 
Merge pull request #2694 from stoeckmann/cleanups

Perform various cleanups

2 months agorar: Fix typos in comments 2694/head
Tobias Stoeckmann [Wed, 9 Jul 2025 21:11:20 +0000 (23:11 +0200)] 
rar: Fix typos in comments

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_read: Fix formatting
Tobias Stoeckmann [Wed, 9 Jul 2025 21:11:00 +0000 (23:11 +0200)] 
archive_read: Fix formatting

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoSECURITY.md: Turn singular into plural
Tobias Stoeckmann [Wed, 9 Jul 2025 21:10:29 +0000 (23:10 +0200)] 
SECURITY.md: Turn singular into plural

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agomtree: Fix grammar and typos
Tobias Stoeckmann [Wed, 9 Jul 2025 21:04:00 +0000 (23:04 +0200)] 
mtree: Fix grammar and typos

Fix grammar and typos in comments and error messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoarchive_string: Use correct data types
Tobias Stoeckmann [Wed, 9 Jul 2025 21:00:38 +0000 (23:00 +0200)] 
archive_string: Use correct data types

If it's already known that we use variables for calculations with
size_t, use size_t for them directly instead of int, even if values
fit.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoFix formatting in archive_string_sprintf.c
Tobias Stoeckmann [Wed, 9 Jul 2025 20:58:38 +0000 (22:58 +0200)] 
Fix formatting in archive_string_sprintf.c

Do not mix tabs and spaces if not needed.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agotar: Remove unneeded casts
Tobias Stoeckmann [Wed, 9 Jul 2025 20:57:40 +0000 (22:57 +0200)] 
tar: Remove unneeded casts

The variable size is already of type size_t. No need to cast it again
to size_t.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 months agoDefine ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto to 1
Tobias Stoeckmann [Wed, 9 Jul 2025 20:55:12 +0000 (22:55 +0200)] 
Define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto to 1

All other define statements set a value. Set one here as well for
maximum compatibility.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 months agoDo not truncate seek requests 2686/head
Tobias Stoeckmann [Fri, 27 Jun 2025 15:24:15 +0000 (17:24 +0200)] 
Do not truncate seek requests

If a seek cannot be fulfilled, fail directly with EOVERFLOW to match
regular lseek behavior.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 months agoFix Windows off_t handling
Tobias Stoeckmann [Fri, 27 Jun 2025 15:04:44 +0000 (17:04 +0200)] 
Fix Windows off_t handling

The off_t datatype in Windows is 32 bit, which leads to issues when
handling files larger than 2 GB.

Add a wrapper around fstat/stat calls to return a struct which has a
properly sized st_size variable. On systems with an off_t representing
the actual system limits, use the native system calls.

This also fixes mtree's checkfs option with large files on Windows.

Fixes https://github.com/libarchive/libarchive/issues/2685
Fixes 89b8c35ff4b5addc08a85bf5df02b407f8af1f6c

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 months agoMerge pull request #2691 from kientzle/kientzle-issue2681
Tim Kientzle [Sun, 29 Jun 2025 19:03:51 +0000 (12:03 -0700)] 
Merge pull request #2691 from kientzle/kientzle-issue2681

Add missing test file

3 months agoAdd missing test file 2691/head
Tim Kientzle [Sun, 29 Jun 2025 03:45:14 +0000 (20:45 -0700)] 
Add missing test file

3 months agoMerge pull request #2664 from fedegiova/fix_leak_for_cb_error
Tim Kientzle [Sun, 29 Jun 2025 02:15:32 +0000 (19:15 -0700)] 
Merge pull request #2664 from fedegiova/fix_leak_for_cb_error

Fix a memory leak if write callback error early

3 months agoMerge pull request #2658 from stoeckmann/skip_tests
Tim Kientzle [Sun, 29 Jun 2025 02:14:17 +0000 (19:14 -0700)] 
Merge pull request #2658 from stoeckmann/skip_tests

Skip tests if respective support is missing

3 months agoMerge pull request #2673 from 004helix/master
Tim Kientzle [Sun, 29 Jun 2025 02:10:27 +0000 (19:10 -0700)] 
Merge pull request #2673 from 004helix/master

archive_cryptor_private.h: check message digest functions are enabled for windows

3 months agoMerge pull request #2679 from AZero13/error
Tim Kientzle [Sun, 29 Jun 2025 02:09:12 +0000 (19:09 -0700)] 
Merge pull request #2679 from AZero13/error

Handle possible errors from system calls

3 months agoMerge pull request #2687 from hemant-jadhav-emerson/master
Tim Kientzle [Sun, 29 Jun 2025 02:04:30 +0000 (19:04 -0700)] 
Merge pull request #2687 from hemant-jadhav-emerson/master

Supress restrict keyword for msc_ver older than 1927

3 months agoMerge pull request #2689 from ElvishJerricco/linux-fs-flags
Tim Kientzle [Sat, 28 Jun 2025 21:23:02 +0000 (14:23 -0700)] 
Merge pull request #2689 from ElvishJerricco/linux-fs-flags

clear_nochange_fflags: Use linux FS flags

3 months agoMerge pull request #2684 from DHowett/dev/duhowett/shim_open
Tim Kientzle [Sat, 28 Jun 2025 21:22:26 +0000 (14:22 -0700)] 
Merge pull request #2684 from DHowett/dev/duhowett/shim_open

win32: shim wopen, and make both open/wopen use _s "secure" variant

3 months agoMerge pull request #2688 from stoeckmann/entry_off32
Tim Kientzle [Sat, 28 Jun 2025 21:11:17 +0000 (14:11 -0700)] 
Merge pull request #2688 from stoeckmann/entry_off32

Ignore sizes which do not fit into off_t

3 months agoclear_nochange_fflags: Use linux FS flags 2689/head
Will Fancher [Fri, 27 Jun 2025 23:09:15 +0000 (19:09 -0400)] 
clear_nochange_fflags: Use linux FS flags

3 months agoIgnore sizes which do not fit into off_t 2688/head
Tobias Stoeckmann [Fri, 27 Jun 2025 15:06:00 +0000 (17:06 +0200)] 
Ignore sizes which do not fit into off_t

It is possible to handle entries and files with sizes which do not fit
into off_t of the current system (Windows always has 32 bit off_t and
32 bit systems without large file support also have 32 bit off_t).

Set sizes to 0 in such cases. The fstat system call would return -1 and
set errno to EOVERFLOW, but that's not how archive_entry_set_size acts.
It would simply ignore negative values and set the size to 0.

Actual callers of archive_entry_stat from foreign projects seem to not
even check for NULL return values, so let's try to handle such cases as
nice as possible.

Affects mtree's checkfs option as well (Windows only, 32 bit systems
would simply fail in fstat/stat).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 months agowin32: shim wopen, and make both open/wopen use _s "secure" variant 2684/head
Dustin Howett [Fri, 15 Oct 2021 22:47:53 +0000 (17:47 -0500)] 
win32: shim wopen, and make both open/wopen use _s "secure" variant

The new `__la_wopen` wrapper is a copy of `__la_open` that
expects--rather than converts--a wcs parameter.

The `sopen` variants are offered as "more secure" variants of `open` and
`wopen`; I cannot vouch for their security, but some build systems are
strict about the use of "banned insecure APIs".

I've confirmed that `_wsopen_s` and `_open_s` are present in the Windows
Vista SDK.

I did not confirm that they are available in the Windows XP Platform
SDK, in part because in e61afbd463d1 (2016!) Tim says:

> I'd like to completely remove support for WinXP and earlier.

3 months agoHandle possible errors from system calls 2679/head
Rose [Fri, 20 Jun 2025 17:21:07 +0000 (13:21 -0400)] 
Handle possible errors from system calls

dup, open, etc, can fail and we should not assume they do not.

3 months agoMerge pull request #2672 from AZero13/ferror
Tim Kientzle [Fri, 20 Jun 2025 21:33:45 +0000 (14:33 -0700)] 
Merge pull request #2672 from AZero13/ferror

Fix error checking in writing files

3 months agoFix error checking in writing files 2672/head
Rose [Wed, 11 Jun 2025 19:21:46 +0000 (15:21 -0400)] 
Fix error checking in writing files

For write, 0 may not mean an error at all. We need to instead check for the length not being the same.

With fwrite, because 0 could mean an error, but not always. We must check that we wrote the entire file!

Note that unlike write, fwrite's description according to POSIX does not mention returning a negative type at all. Nor does it say you can retry unlike write.

Finally, with write, we need to check less than 0, not 0, as 0 is a valid return and does not mean an error.

3 months agoMerge pull request #2678 from mostynb/zstd_filter_checksum
Tim Kientzle [Fri, 20 Jun 2025 16:32:51 +0000 (09:32 -0700)] 
Merge pull request #2678 from mostynb/zstd_filter_checksum

Enable Zstandard's checksum feature in the zstd write filter

3 months agoEnable Zstandard's checksum feature in the zstd write filter 2678/head
Mostyn Bramley-Moore [Fri, 20 Jun 2025 12:39:28 +0000 (14:39 +0200)] 
Enable Zstandard's checksum feature in the zstd write filter

Note that this is not enabled when writing .zip or .7z archive formats,
because they already use their own checksums.

Implements #2675.

3 months agoMerge pull request #2677 from AZero13/fwrite
Tim Kientzle [Thu, 19 Jun 2025 23:12:26 +0000 (16:12 -0700)] 
Merge pull request #2677 from AZero13/fwrite

Change error message from "fwrite function failed" to "write function failed"

3 months agoChange error message from "fwrite function failed" to "write function failed" 2677/head
Rose [Thu, 19 Jun 2025 16:00:23 +0000 (12:00 -0400)] 
Change error message from "fwrite function failed" to "write function failed"

We are checking the return value from write, not fwrite, so this message is wrong.

3 months agoMerge pull request #2676 from danyeaw/fix-pkgconf-path
Tim Kientzle [Thu, 19 Jun 2025 15:20:43 +0000 (08:20 -0700)] 
Merge pull request #2676 from danyeaw/fix-pkgconf-path

Fix .pc location when CMAKE_INSTALL_LIBDIR not set

3 months agoFix .pc location when CMAKE_INSTALL_LIBDIR not set 2676/head
Dan Yeaw [Thu, 19 Jun 2025 01:27:04 +0000 (21:27 -0400)] 
Fix .pc location when CMAKE_INSTALL_LIBDIR not set

3 months agoError related to restrict keyword supressed for older vs compiler 2687/head
Hemant [Wed, 18 Jun 2025 19:05:23 +0000 (14:05 -0500)] 
Error related to restrict keyword supressed for older vs compiler

3 months agoError related to restrict keyword supressed for older vs compiler
Hemant [Wed, 18 Jun 2025 18:51:00 +0000 (13:51 -0500)] 
Error related to restrict keyword supressed for older vs compiler