]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
6 days agounzip: Add -f test
Tobias Stoeckmann [Mon, 22 Jun 2026 19:45:44 +0000 (21:45 +0200)] 
unzip: Add -f test

Verify that -f does not create new files and also does not override
files which have a newer timestamp.

This also verifies that creation of timestamps properly works.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
6 days agoMerge pull request #3171 from libarchive/dependabot/github_actions/all-actions-2217aebe03
Martin Matuška [Tue, 23 Jun 2026 07:56:06 +0000 (09:56 +0200)] 
Merge pull request #3171 from libarchive/dependabot/github_actions/all-actions-2217aebe03

CI: Bump actions/checkout from 6.0.3 to 7.0.0 in the all-actions group

6 days agoMerge pull request #3172 from stoeckmann/lafe_fnmatch
Martin Matuška [Tue, 23 Jun 2026 07:42:50 +0000 (09:42 +0200)] 
Merge pull request #3172 from stoeckmann/lafe_fnmatch

libarchive_fe: Import FreeBSD's fnmatch

6 days agotar: mark bsdtar as long-path aware on Windows 3162/head
Reyad Attiyat [Fri, 19 Jun 2026 04:12:24 +0000 (23:12 -0500)] 
tar: mark bsdtar as long-path aware on Windows

 bsdtar's -C/--directory option calls SetCurrentDirectoryW(), which is
 limited to MAX_PATH (260) characters unless the process opts in to long
 path support via an application manifest declaring longPathAware.
 Extracting into (or changing into) a directory whose path exceeds 260
 characters fails with "could not chdir".

 Embed a longPathAware application manifest into bsdtar.exe so these
 operations work for long destination paths. Both Windows build systems
 (CMake and the autotools/Makefile.am build) embed it, using different
 mechanisms per toolchain:

   - MinGW/Clang (GNU ld) do not generate an application manifest, so it
     is compiled from a resource script (bsdtar.rc) via windres. This
     manifest replaces the toolchain default, so it also declares the
     asInvoker execution level explicitly.
   - MSVC's linker already embeds a manifest (resource id 1); a duplicate
     RT_MANIFEST resource fails to link (CVT1100). Instead the manifest is
     merged into the linker's default manifest (asInvoker) by adding it to
     the target sources.

7 days agoMerge pull request #3173 from stoeckmann/cpio_endian
Dustin L. Howett [Mon, 22 Jun 2026 19:39:56 +0000 (14:39 -0500)] 
Merge pull request #3173 from stoeckmann/cpio_endian

cpio: Avoid naming conflict with endian functions

7 days agocpio: Avoid naming conflict with endian functions 3173/head
Tobias Stoeckmann [Mon, 22 Jun 2026 19:23:07 +0000 (21:23 +0200)] 
cpio: Avoid naming conflict with endian functions

The local functions be32dec and le32dec lead to conflicts on NetBSD. Use
a proper prefix as suggested by Dustin L. Howett.

Resolves #3170.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agoMerge pull request #3168 from uchiha-bug-hunter/cpio-write-pathlength-oob
Dustin L. Howett [Mon, 22 Jun 2026 18:42:54 +0000 (13:42 -0500)] 
Merge pull request #3168 from uchiha-bug-hunter/cpio-write-pathlength-oob

cpio: fix OOB read from int pathlength truncation in newc/binary writers

7 days agolibarchive_fe: Import FreeBSD's fnmatch 3172/head
Tobias Stoeckmann [Mon, 22 Jun 2026 18:30:22 +0000 (20:30 +0200)] 
libarchive_fe: Import FreeBSD's fnmatch

If system lacks fnmatch(3), use FreeBSD's fnmatch. It's adjusted for
increased compatibility, i.e. it uses strcoll instead of FreeBSD's
library internals and const char pointers where needed with latest
GNU/Linux toolchains.

FreeBSD source can be obtained here:

https://github.com/freebsd/freebsd-src/blob/dc36d6f9bb1753f3808552f3afd30eda9a7b206a/lib/libc/gen/fnmatch.c

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
7 days agoCI: Bump actions/checkout from 6.0.3 to 7.0.0 in the all-actions group 3171/head
dependabot[bot] [Mon, 22 Jun 2026 16:12:57 +0000 (16:12 +0000)] 
CI: Bump actions/checkout from 6.0.3 to 7.0.0 in the all-actions group

Bumps the all-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).

Updates `actions/checkout` from 6.0.3 to 7.0.0
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/df4cb1c069e1874edd31b4311f1884172cec0e10...9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
7 days agocpio: fix OOB read from int pathlength truncation in newc/binary writers 3168/head
uchiha-bug-hunter [Mon, 22 Jun 2026 09:41:13 +0000 (15:11 +0530)] 
cpio: fix OOB read from int pathlength truncation in newc/binary writers

7 days agoMerge pull request #3166 from stoeckmann/unzip_p_enc_test
Tobias Stoeckmann [Mon, 22 Jun 2026 05:44:58 +0000 (07:44 +0200)] 
Merge pull request #3166 from stoeckmann/unzip_p_enc_test

unzip: Skip another test if zlib unavailable

8 days agounzip: Skip another test if zlib unavailable 3166/head
Tobias Stoeckmann [Sun, 21 Jun 2026 19:07:43 +0000 (21:07 +0200)] 
unzip: Skip another test if zlib unavailable

The input file in test_P_encryption uses deflate, which is only
available if zlib is available. Skip the test if built without zlib.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 days agoMerge pull request #3164 from stoeckmann/iso9660_realloc
Dustin L. Howett [Sat, 20 Jun 2026 16:34:51 +0000 (11:34 -0500)] 
Merge pull request #3164 from stoeckmann/iso9660_realloc

9 days agoiso9660: Remove realloc from idr_extend_identifier 3164/head
Tobias Stoeckmann [Fri, 19 Jun 2026 15:30:18 +0000 (17:30 +0200)] 
iso9660: Remove realloc from idr_extend_identifier

Allocate enough memory with initial malloc for possible additions, which
removes any kind of error handling required in idr_extend_identifier.

The additional memory allocated was already large enough. Clarify
exactly where the required amount comes from by using named constants.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
10 days agoMerge pull request #3165 from stoeckmann/error_zero
Dustin L. Howett [Fri, 19 Jun 2026 22:19:18 +0000 (17:19 -0500)] 
Merge pull request #3165 from stoeckmann/error_zero

Do not set 0 as error code, since this will be printed as success. Use proper error codes in various places for better error messages.

10 days agoAvoid 0 as error code 3165/head
Tobias Stoeckmann [Fri, 19 Jun 2026 15:45:42 +0000 (17:45 +0200)] 
Avoid 0 as error code

Do not set 0 as error code, since this will be printed as success. Use
proper error codes in various places for better error messages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
10 days agoMerge pull request #2918 from aale24/fix-test-format-newc-race
Martin Matuška [Fri, 19 Jun 2026 07:48:25 +0000 (09:48 +0200)] 
Merge pull request #2918 from aale24/fix-test-format-newc-race

Fix test_format_newc timestamp race condition

11 days agoMerge pull request #3158 from stoeckmann/cpio_write
Tobias Stoeckmann [Thu, 18 Jun 2026 20:51:43 +0000 (22:51 +0200)] 
Merge pull request #3158 from stoeckmann/cpio_write

cpio: Fix writer OOB read with very long filenames

11 days agoMerge commit from fork
Dustin L. Howett [Thu, 18 Jun 2026 16:41:47 +0000 (11:41 -0500)] 
Merge commit from fork

xattr/sparse: Fix UAF by nullifying pointer

11 days agoMerge pull request #3159 from stoeckmann/ckd_size
Martin Matuška [Thu, 18 Jun 2026 14:37:15 +0000 (16:37 +0200)] 
Merge pull request #3159 from stoeckmann/ckd_size

Use checked size_t arithmetic

11 days agoUse checked size_t arithmetic 3159/head
Tobias Stoeckmann [Wed, 17 Jun 2026 17:52:36 +0000 (19:52 +0200)] 
Use checked size_t arithmetic

Add archive_ckd_add_size and archive_ckd_mul_size. Use them for checked
arithmetic throughout the source code where explicit SIZE_MAX checks
were performed.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
11 days agoMerge pull request #3135 from stoeckmann/read_ahead_format
Dustin L. Howett [Thu, 18 Jun 2026 02:20:51 +0000 (21:20 -0500)] 
Merge pull request #3135 from stoeckmann/read_ahead_format

formats: Simplify `__archive_read_ahead` use

12 days agoFix reading ppmd8 zipx with ZIP_LENGTH_AT_END flag from non-seekable stream 3160/head
GeorgH93 [Tue, 16 Jun 2026 23:26:54 +0000 (01:26 +0200)] 
Fix reading ppmd8 zipx with ZIP_LENGTH_AT_END flag from non-seekable stream

12 days agozip: fix OOB read in streaming WinZip-AES xz decryption
GeorgH93 [Wed, 17 Jun 2026 20:26:28 +0000 (22:26 +0200)] 
zip: fix OOB read in streaming WinZip-AES xz decryption

entry_bytes_remaining goes negative for a streaming entry after the AES
header is subtracted; zip_read_data_zipx_xz passed it to zip_read_decrypt
as a size_t, causing an out-of-bounds read.

Co-Authored-By: Marco <marco@mpreimann.de>
12 days agoFix reading lzma zipx with ZIP_LENGTH_AT_END flag from non-seekable stream
GeorgH93 [Mon, 15 Jun 2026 23:27:54 +0000 (01:27 +0200)] 
Fix reading lzma zipx with ZIP_LENGTH_AT_END flag from non-seekable stream

12 days agoFix reading xz zipx with ZIP_LENGTH_AT_END flag from non-seekable stream
GeorgH93 [Mon, 15 Jun 2026 21:32:59 +0000 (23:32 +0200)] 
Fix reading xz zipx with ZIP_LENGTH_AT_END flag from non-seekable stream

12 days agoFix reading bzip2 zipx with ZIP_LENGTH_AT_END flag from non-seekable stream
GeorgH93 [Mon, 15 Jun 2026 21:21:52 +0000 (23:21 +0200)] 
Fix reading bzip2 zipx with ZIP_LENGTH_AT_END flag from non-seekable stream

12 days agoFix reading zstd zipx with ZIP_LENGTH_AT_END flag from non-seekable stream
GeorgH93 [Mon, 15 Jun 2026 21:16:02 +0000 (23:16 +0200)] 
Fix reading zstd zipx with ZIP_LENGTH_AT_END flag from non-seekable stream

12 days agoExpand testing for encrypted zipx to also test streaming headers and non seekable...
GeorgH93 [Mon, 15 Jun 2026 21:14:56 +0000 (23:14 +0200)] 
Expand testing for encrypted zipx to also test streaming headers and non seekable data sources

12 days agoformats: Simplify __archive_read_ahead use 3135/head
Tobias Stoeckmann [Thu, 11 Jun 2026 15:42:46 +0000 (17:42 +0200)] 
formats: Simplify __archive_read_ahead use

Set the third argument to NULL if the amount of actually read bytes is
not needed. This simplifies code audits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agocpio: Fix OOB read with very long filenames 3158/head
Tobias Stoeckmann [Wed, 17 Jun 2026 17:43:18 +0000 (19:43 +0200)] 
cpio: Fix OOB read with very long filenames

If a filename is larger than INT_MAX, eventual size_t/int/size_t
conversions lead to huge size_t values and subsequent OOB reads.

Use correct values. Before this would lead to unnecessary writes, the
filename length field check already aborts the operation.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agocpio: Verify that filename length fits into field
Tobias Stoeckmann [Wed, 17 Jun 2026 17:36:42 +0000 (19:36 +0200)] 
cpio: Verify that filename length fits into field

If the filename length cannot be represented as octal in its field,
return an error instead of silently truncating the value.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agoMerge pull request #3157 from libarchive/dependabot/github_actions/all-actions-0a5d8bb8fa
Martin Matuška [Wed, 17 Jun 2026 09:30:05 +0000 (11:30 +0200)] 
Merge pull request #3157 from libarchive/dependabot/github_actions/all-actions-0a5d8bb8fa

CI: Bump the all-actions group across 1 directory with 5 updates

12 days agoMerge pull request #3150 from DHowett/ci/windows-package-dependencies
Martin Matuška [Wed, 17 Jun 2026 07:29:46 +0000 (09:29 +0200)] 
Merge pull request #3150 from DHowett/ci/windows-package-dependencies

build: windows: get all CI dependencies from a package manager

12 days agoCI: Bump the all-actions group across 1 directory with 5 updates 3157/head
dependabot[bot] [Wed, 17 Jun 2026 07:25:32 +0000 (07:25 +0000)] 
CI: Bump the all-actions group across 1 directory with 5 updates

Bumps the all-actions group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [acj/freebsd-firecracker-action](https://github.com/acj/freebsd-firecracker-action) | `0.9.1` | `0.10.0` |
| [actions/checkout](https://github.com/actions/checkout) | `6.0.1` | `6.0.3` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `6.0.0` | `7.0.1` |
| [cygwin/cygwin-install-action](https://github.com/cygwin/cygwin-install-action) | `6.0.1` | `6.0.2` |
| [github/codeql-action](https://github.com/github/codeql-action) | `4.31.9` | `4.36.2` |

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

Updates `actions/checkout` from 6.0.1 to 6.0.3
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/8e8c483db84b4bee98b60c0593521ed34d9990e8...df4cb1c069e1874edd31b4311f1884172cec0e10)

Updates `actions/upload-artifact` from 6.0.0 to 7.0.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/b7c566a772e6b6bfb58ed0dc250532a479d7789f...043fb46d1a93c77aae656e7c1c64a875d1fc6a0a)

Updates `cygwin/cygwin-install-action` from 6.0.1 to 6.0.2
- [Release notes](https://github.com/cygwin/cygwin-install-action/releases)
- [Commits](https://github.com/cygwin/cygwin-install-action/compare/711d29f3da23c9f4a1798e369a6f01198c13b11a...3f0a3f9f988f7e96b8c18098ae05eaec175f5b52)

Updates `github/codeql-action` from 4.31.9 to 4.36.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/5d4e8d1aca955e8d8589aabd499c5cae939e33c7...8aad20d150bbac5944a9f9d289da16a4b0d87c1e)

---
updated-dependencies:
- dependency-name: acj/freebsd-firecracker-action
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: actions/checkout
  dependency-version: 6.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: cygwin/cygwin-install-action
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: github/codeql-action
  dependency-version: 4.36.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
12 days agoMerge pull request #3144 from stoeckmann/cab_truncation
Martin Matuška [Wed, 17 Jun 2026 06:49:31 +0000 (08:49 +0200)] 
Merge pull request #3144 from stoeckmann/cab_truncation

cab: Improve truncation detection

12 days agoMerge pull request #3134 from stoeckmann/archive_integer
Martin Matuška [Wed, 17 Jun 2026 06:48:55 +0000 (08:48 +0200)] 
Merge pull request #3134 from stoeckmann/archive_integer

Introduce `archive_integer.h` for checked arithmetic

12 days agoMerge pull request #3145 from stoeckmann/cab_max_namelen
Tobias Stoeckmann [Wed, 17 Jun 2026 06:32:03 +0000 (08:32 +0200)] 
Merge pull request #3145 from stoeckmann/cab_max_namelen

cab: Properly limit maximum name length

12 days agoMerge pull request #3153 from stoeckmann/cab_multi
Dustin L. Howett [Wed, 17 Jun 2026 02:57:14 +0000 (21:57 -0500)] 
Merge pull request #3153 from stoeckmann/cab_multi

cab: Fix multi volume parser

13 days agocab: Fix name reading 3153/head
Tobias Stoeckmann [Tue, 16 Jun 2026 19:40:48 +0000 (21:40 +0200)] 
cab: Fix name reading

Archives are not necessarily 256 bytes long, e.g. the last part of a
multi volume archive. Only try to read up to 256 bytes when looking for
an archive or disk name, not necessarily exactly 256 bytes. This matches
the behavior of regular entry name lookups.

Also, disk names can be empty. Handle this as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agocab: Add test for multi volume archives
Tobias Stoeckmann [Tue, 16 Jun 2026 19:37:55 +0000 (21:37 +0200)] 
cab: Add test for multi volume archives

The cab reader does not support multi volume archives, but it should be
able to read the files to print information about content.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agoMerge pull request #3142 from datauwu/tar-avoid-wcs-slash-check
Dustin L. Howett [Tue, 16 Jun 2026 01:00:23 +0000 (20:00 -0500)] 
Merge pull request #3142 from datauwu/tar-avoid-wcs-slash-check

tar: avoid wide pathname conversion for trailing slash check

2 weeks agobuild: use vcpkg for Windows-MSVC's dependencies 3150/head
Dustin L. Howett [Sun, 7 Jul 2024 23:59:07 +0000 (18:59 -0500)] 
build: use vcpkg for Windows-MSVC's dependencies

2 weeks agobuild: move library dependencies into mingw install
Dustin L. Howett [Sun, 14 Jun 2026 15:22:41 +0000 (10:22 -0500)] 
build: move library dependencies into mingw install

2 weeks agobuild: use the setup-msys2 action rather than chocolatey
Dustin L. Howett [Mon, 1 Jun 2026 14:32:15 +0000 (10:32 -0400)] 
build: use the setup-msys2 action rather than chocolatey

This will give us some ability in the future to vary `MSYSTEM` and
produce different MSYS builds.

2 weeks agoMerge pull request #3148 from XananasX7/ci/pin-actions
Dustin L. Howett [Mon, 15 Jun 2026 20:25:35 +0000 (15:25 -0500)] 
Merge pull request #3148 from XananasX7/ci/pin-actions

ci: pin acj/freebsd-firecracker-action to full commit SHA

2 weeks agoMerge pull request #3149 from DHowett/fix-mingw-tests
Dustin L. Howett [Mon, 15 Jun 2026 20:24:06 +0000 (15:24 -0500)] 
Merge pull request #3149 from DHowett/fix-mingw-tests

2 weeks agotar: use filesystem-neutral replacement characters in the -s test 3149/head
Dustin L. Howett [Sun, 14 Jun 2026 20:01:29 +0000 (15:01 -0500)] 
tar: use filesystem-neutral replacement characters in the -s test

2 weeks agotest: promote the win32-repairing systemf wrapper to all systemf calls
Dustin L. Howett [Sun, 14 Jun 2026 20:01:00 +0000 (15:01 -0500)] 
test: promote the win32-repairing systemf wrapper to all systemf calls

2 weeks agoci: pin acj/freebsd-firecracker-action to full commit SHA 3148/head
XananasX7 [Sun, 14 Jun 2026 18:38:24 +0000 (18:38 +0000)] 
ci: pin acj/freebsd-firecracker-action to full commit SHA

  acj/freebsd-firecracker-action: @v0.9.1 -> @bab3e77871573c7943b80816f1641b6c1ce36896

2 weeks agoMerge pull request #3143 from stoeckmann/7zip_size_int64
Dustin L. Howett [Sun, 14 Jun 2026 15:01:50 +0000 (10:01 -0500)] 
Merge pull request #3143 from stoeckmann/7zip_size_int64

7zip: Avoid unnecessary int64_t size_t casts

2 weeks agoMerge pull request #3146 from stoeckmann/size_t_off
Dustin L. Howett [Sun, 14 Jun 2026 14:59:01 +0000 (09:59 -0500)] 
Merge pull request #3146 from stoeckmann/size_t_off

read_disk: Check if off_t can overflow size_t

2 weeks agoread_disk: Check if off_t can overflow size_t 3146/head
Tobias Stoeckmann [Sun, 14 Jun 2026 09:14:03 +0000 (11:14 +0200)] 
read_disk: Check if off_t can overflow size_t

Make sure that the content of the link can fit into a size_t. This
should be always true, but be cautious with 32 bit systems and very
weird filesystems (possibly through fuse).

I took SSIZE_MAX as upper limit due to signedness and eventual readlink
calls which would fail with larger values anyway.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks ago7zip: Avoid unnecessary int64_t size_t casts 3143/head
Tobias Stoeckmann [Sat, 13 Jun 2026 09:01:42 +0000 (11:01 +0200)] 
7zip: Avoid unnecessary int64_t size_t casts

Use size_t for avail_in, avail_out and stream_in for ppmd streams.

The fields avail_in and avail_out values are set in function decompress
based on size_t variables (t_avail_in/t_avail_out) and eventually
written back. The stream_in field is only incremented.

The actual use case happens within ppmd_read to support situations in
which not enough bytes are available. In such cases, more bytes are read
on demand but not written into next_in.

In such cases, avail_in can turn negative and next_in can point outside
of its allocated memory area.

Since stream_in is always incremented by one, it won't overflow on real
hardware, given that size_t would address the whole available heap
space.

Make sure that avail_in never turns negative (which allows the size_t
usage) and also guarantee that t_avail_in will never wrap around,
leading to a huge "used" value.

As a bonus, __archive_read_ahead can be reliably called with a NULL
argument now, since no more casting occurs for second argument, which
was missing in the test.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Properly limit maximum name length 3145/head
Tobias Stoeckmann [Sat, 13 Jun 2026 14:08:10 +0000 (16:08 +0200)] 
cab: Properly limit maximum name length

The cab_read_ahead_remaining function might return more bytes through
avail than initially asked for. The given limit is 255+1, i.e. the
maximum file name length.

While it's not a big deal for libarchive to handle file names longer
than that, the CAB format does not allow longer names.

Limit the amount of available bytes to the given argument for proper
checking.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Improve truncation detection 3144/head
Tobias Stoeckmann [Sat, 13 Jun 2026 14:02:38 +0000 (16:02 +0200)] 
cab: Improve truncation detection

If not enough bytes are available, __archive_read_ahead will return the
amount of bytes still available, which can be larger than 0. Only in
error cases, a negative value is returned.

Check the return pointer instead. It simplifies the error handling,
allows a NULL argument, and covers more truncation issues.

Right now, a NULL pointer with a non-zero size could be further
processed, which just asks for more technical or logical issues to
arise.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agotar: avoid wide pathname conversion for trailing slash check 3142/head
data [Sat, 13 Jun 2026 00:12:52 +0000 (08:12 +0800)] 
tar: avoid wide pathname conversion for trailing slash check

Avoid requesting the wide-character pathname when the tar reader only
needs to check whether a regular entry name ends in '/'.

archive_entry_pathname_w() can lazily convert the pathname to WCS. In the
common tar read path, the multibyte pathname is already available, so
checking it first avoids unnecessary per-entry conversion. The WCS fallback
is kept for cases where the multibyte pathname is unavailable.

2 weeks agotime: Use archive_integer.h 3134/head
Tobias Stoeckmann [Wed, 10 Jun 2026 18:09:24 +0000 (20:09 +0200)] 
time: Use archive_integer.h

Use archive_integer's checked integer arithmetic.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agotime: Sort header includes
Tobias Stoeckmann [Wed, 10 Jun 2026 18:08:33 +0000 (20:08 +0200)] 
time: Sort header includes

While at it, add header checks.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoUse archive_integer.h for number parsers
Tobias Stoeckmann [Wed, 10 Jun 2026 18:06:40 +0000 (20:06 +0200)] 
Use archive_integer.h for number parsers

Use checked integer arithmetic to detect integer overflows.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoAdd archive_integer.h
Tobias Stoeckmann [Wed, 10 Jun 2026 17:56:40 +0000 (19:56 +0200)] 
Add archive_integer.h

The archive_integer.h header offers various integer operations to
libarchive, utilizing system functionality where possible.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoMerge pull request #3138 from datauwu/tar-ustar-pathname-fastpath
Dustin L. Howett [Fri, 12 Jun 2026 18:17:58 +0000 (13:17 -0500)] 
Merge pull request #3138 from datauwu/tar-ustar-pathname-fastpath

2 weeks agoMerge pull request #3140 from DHowett/dh/write-free-1
Tobias Stoeckmann [Fri, 12 Jun 2026 16:05:13 +0000 (18:05 +0200)] 
Merge pull request #3140 from DHowett/dh/write-free-1

test: remove one new instance of assertEqualIntA(...free...)

2 weeks agotest: remove one new instance of assertEqualIntA(...free...) 3140/head
Dustin L. Howett [Fri, 12 Jun 2026 15:30:13 +0000 (10:30 -0500)] 
test: remove one new instance of assertEqualIntA(...free...)

2 weeks agoMerge pull request #2865 from GeorgH93/read_zipx_encryption
Dustin L. Howett [Fri, 12 Jun 2026 15:28:45 +0000 (10:28 -0500)] 
Merge pull request #2865 from GeorgH93/read_zipx_encryption

Add support for reading encrypted zipx formats (bzip2, lzma, ppmd, xz, zstd)

2 weeks agoIntroduce zipx encryption handling for zstd compressed zip files 2865/head
GeorgH93 [Wed, 10 Jun 2026 19:35:48 +0000 (21:35 +0200)] 
Introduce zipx encryption handling for zstd compressed zip files

2 weeks agoIntroduce zipx encryption handling for bzip2 compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:35:20 +0000 (21:35 +0200)] 
Introduce zipx encryption handling for bzip2 compressed zip files

2 weeks agoIntroduce zipx encryption handling for lzma compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:34:27 +0000 (21:34 +0200)] 
Introduce zipx encryption handling for lzma compressed zip files

2 weeks agoIntroduce zipx encryption handling for xz compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:33:16 +0000 (21:33 +0200)] 
Introduce zipx encryption handling for xz compressed zip files

2 weeks agoIntroduce zipx encryption handling for ppmd compressed zip files
GeorgH93 [Wed, 10 Jun 2026 19:31:46 +0000 (21:31 +0200)] 
Introduce zipx encryption handling for ppmd compressed zip files

2 weeks agoAdd test for creating encrypted zip file with libarchive and reading it again with...
GeorgH93 [Wed, 10 Jun 2026 19:27:29 +0000 (21:27 +0200)] 
Add test for creating encrypted zip file with libarchive and reading it again with libarchive

2 weeks agoRefactor zip archive reader, by moving decryption related code blocks into their...
GeorgH93 [Wed, 10 Jun 2026 19:23:31 +0000 (21:23 +0200)] 
Refactor zip archive reader, by moving decryption related code blocks into their own functions to make them reusable for compression formats other than deflate

2 weeks agotar reader: avoid temporary buffer for empty-prefix ustar names 3138/head
data [Thu, 11 Jun 2026 19:36:33 +0000 (03:36 +0800)] 
tar reader: avoid temporary buffer for empty-prefix ustar names

For empty-prefix ustar entries, copy the fixed-width name field
directly into the archive entry instead of first building a temporary
archive_string.

This avoids a temporary buffer allocation and intermediate copy in the
common case. It also fixes a small fatal-error leak by freeing the
temporary prefix/name buffer before returning on pathname conversion
failure.

2 weeks agoMerge pull request #2923 from bililateral/pr-7zip-numfiles-oom
Tobias Stoeckmann [Fri, 12 Jun 2026 06:27:25 +0000 (08:27 +0200)] 
Merge pull request #2923 from bililateral/pr-7zip-numfiles-oom

7zip: sanity-check FilesInfo NumFiles before allocating entries

2 weeks agoMerge pull request #3105 from i1011/rar-unbounded-staticdata-fix
Dustin L. Howett [Fri, 12 Jun 2026 04:09:19 +0000 (23:09 -0500)] 
Merge pull request #3105 from i1011/rar-unbounded-staticdata-fix

rar: Add missing bound check for staticdata

2 weeks agoMerge pull request #3137 from stoeckmann/typos_style
Dustin L. Howett [Fri, 12 Jun 2026 04:05:03 +0000 (23:05 -0500)] 
Merge pull request #3137 from stoeckmann/typos_style

Fix minor non-functional issues

2 weeks agoMerge pull request #3136 from stoeckmann/counters
Dustin L. Howett [Thu, 11 Jun 2026 20:41:05 +0000 (15:41 -0500)] 
Merge pull request #3136 from stoeckmann/counters

Remove unneeded counters

2 weeks agocpio: Remove unneeded cast 3137/head
Tobias Stoeckmann [Thu, 11 Jun 2026 16:59:29 +0000 (18:59 +0200)] 
cpio: Remove unneeded cast

The variable l is uint64_t, the return type is uint64_t. Do not cast to
int64_t.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoFix whitespace issues
Tobias Stoeckmann [Thu, 11 Jun 2026 16:59:18 +0000 (18:59 +0200)] 
Fix whitespace issues

No functional change

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoFix typos in comments and documentation
Tobias Stoeckmann [Thu, 11 Jun 2026 16:58:19 +0000 (18:58 +0200)] 
Fix typos in comments and documentation

No functional change

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agofilters: Remove unneeded counters 3136/head
Tobias Stoeckmann [Thu, 11 Jun 2026 16:57:36 +0000 (18:57 +0200)] 
filters: Remove unneeded counters

These counters are written to, but they are never read. Remove them for
easier code audits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoformats: Remove unneeded counters
Tobias Stoeckmann [Thu, 11 Jun 2026 16:56:59 +0000 (18:56 +0200)] 
formats: Remove unneeded counters

These counters are written to, but they are never read. Remove them for
easier code audits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agorar: Reject staticdatalen larger than VM memory 3105/head
i1011 [Thu, 11 Jun 2026 16:51:16 +0000 (00:51 +0800)] 
rar: Reject staticdatalen larger than VM memory

2 weeks agoMerge commit from fork
Tobias Stoeckmann [Thu, 11 Jun 2026 15:41:31 +0000 (17:41 +0200)] 
Merge commit from fork

unzip: reject absolute or traversing symlink targets

2 weeks agoRefactor the zip_winzip_aes_large test to support parameterized file ordering, file...
GeorgH93 [Wed, 10 Jun 2026 19:14:02 +0000 (21:14 +0200)] 
Refactor the zip_winzip_aes_large test to support parameterized file ordering, file mode and compression type

2 weeks ago7zip: sanity-check FilesInfo NumFiles before allocating entries 2923/head
bililateral [Wed, 18 Mar 2026 08:37:45 +0000 (16:37 +0800)] 
7zip: sanity-check FilesInfo NumFiles before allocating entries

2 weeks agoMerge pull request #3048 from legnaleurc/fix/rar-reset-lz-table
Dustin L. Howett [Wed, 10 Jun 2026 01:30:47 +0000 (20:30 -0500)] 
Merge pull request #3048 from legnaleurc/fix/rar-reset-lz-table

rar: reset low-distance state for new LZ tables

2 weeks agoMerge pull request #3047 from legnaleurc/fix/rar-recovery-record
Dustin L. Howett [Wed, 10 Jun 2026 01:26:31 +0000 (20:26 -0500)] 
Merge pull request #3047 from legnaleurc/fix/rar-recovery-record

rar: skip NEWSUB payloads without size cap

2 weeks agoMerge pull request #3132 from stoeckmann/lz4_double_free
Dustin L. Howett [Wed, 10 Jun 2026 01:14:28 +0000 (20:14 -0500)] 
Merge pull request #3132 from stoeckmann/lz4_double_free

lz4: Fix double-free on reallocation failure
Alternative version of https://github.com/libarchive/libarchive/pull/2945 which removes the test (which requires a modified malloc to actually fail the 4 MB allocation).

2 weeks agoMerge pull request #3034 from datauwu/master
Dustin L. Howett [Tue, 9 Jun 2026 22:00:55 +0000 (17:00 -0500)] 
Merge pull request #3034 from datauwu/master

2 weeks agoFix double-free in LZ4 filter on reallocation failure (CWE-415) 3132/head
isomorph-cyber [Wed, 25 Mar 2026 03:19:10 +0000 (23:19 -0400)] 
Fix double-free in LZ4 filter on reallocation failure (CWE-415)

lz4_allocate_out_block() frees state->out_block without NULLing
the pointer. If the subsequent malloc fails, the function returns
ARCHIVE_FATAL with a dangling pointer. lz4_filter_close() later
calls free(state->out_block) again, triggering a double-free.

Also, state->out_block_size was updated before checking if malloc
succeeded, leaving inconsistent metadata on failure.

Fix both lz4_allocate_out_block() and lz4_allocate_out_block_for_legacy():
- NULL the pointer immediately after free
- Move size update to after malloc succeeds
- Reset size to 0 on allocation failure

2 weeks ago7zip: reject malformed SubStreamsInfo metadata 3034/head
datauwu [Tue, 9 Jun 2026 19:10:27 +0000 (03:10 +0800)] 
7zip: reject malformed SubStreamsInfo metadata

Validate the accumulated unpack stream count before allocating
per-substream metadata.

Reject folders that declare multiple substreams without kSize metadata,
since the parser needs those sizes to describe the stream layout.

Drop the explicit digest zeroing loop. The arrays are allocated with
calloc(), so the entries are already initialized.

2 weeks ago7zip: add malformed SubStreamsInfo test
datauwu [Tue, 9 Jun 2026 19:10:27 +0000 (03:10 +0800)] 
7zip: add malformed SubStreamsInfo test

Add a 7z regression test for malformed SubStreamsInfo metadata that
declares more than one unpack stream without the kSize data needed to
describe those streams.

Store the archive as a .7z.uu file, matching the existing malformed
7z tests.

2 weeks agounzip: reject absolute or traversing symlink targets
Dustin L. Howett [Tue, 9 Jun 2026 16:16:02 +0000 (11:16 -0500)] 
unzip: reject absolute or traversing symlink targets

This is overly broad, and will reject some well-formed archives which
contain symlinks to trees which exist in the archive; however, this is
the best we can do without some rudimentary path parsing.

Fixes GHSA-q4gj-vh8c-67p8

2 weeks agoMerge pull request #2954 from ShelpAm/master
Dustin L. Howett [Tue, 9 Jun 2026 14:55:46 +0000 (09:55 -0500)] 
Merge pull request #2954 from ShelpAm/master

fix: zstd not found on Windows

2 weeks agoMerge pull request #2967 from bgilbert/deflate
Martin Matuška [Tue, 9 Jun 2026 06:40:07 +0000 (08:40 +0200)] 
Merge pull request #2967 from bgilbert/deflate

Fix `test_write_filter_gzip` on Ubuntu s390x

2 weeks agoMerge pull request #3131 from stoeckmann/rpm_fsm
Martin Matuška [Tue, 9 Jun 2026 06:35:23 +0000 (08:35 +0200)] 
Merge pull request #3131 from stoeckmann/rpm_fsm

rpm: Refactor filter

2 weeks agoMerge pull request #3128 from stoeckmann/into_fd
Martin Matuška [Tue, 9 Jun 2026 06:31:24 +0000 (08:31 +0200)] 
Merge pull request #3128 from stoeckmann/into_fd

Improve `archive_read_data_into_fd` with sparse files

2 weeks agoMerge pull request #3121 from stoeckmann/rar5_bytes_remaining
Martin Matuška [Tue, 9 Jun 2026 06:30:03 +0000 (08:30 +0200)] 
Merge pull request #3121 from stoeckmann/rar5_bytes_remaining

rar5: fix signed integer underflow in bytes_remaining

2 weeks agoMerge pull request #3120 from stoeckmann/archive_endian
Martin Matuška [Tue, 9 Jun 2026 06:29:23 +0000 (08:29 +0200)] 
Merge pull request #3120 from stoeckmann/archive_endian

Extend `archive_endian.h` usage