8131 Commits
Author SHA1 Message Date
datauwu 4a448d488c mtree: use archive_string_dirname to roll back paths
Replace the manual reverse scan with archive_string_dirname while
preserving the empty path representation.
2026-07-21 17:43:14 +08:00
datauwu b15a0a0bb5 iso9660: remove per-reader zero comparison buffer
Check reserved fields by comparing adjacent bytes after confirming the
first byte is zero. This preserves the memcmp fast path and removes
2 KiB from each ISO9660 reader state.
2026-07-21 17:07:05 +08:00
Dustin L. Howett 33da30bd9c Merge pull request #3316 from libarchive/dependabot/github_actions/all-actions-3c55da1aaa
CI: Bump the all-actions group with 6 updates
2026-07-20 19:36:20 -05:00
Tobias Stoeckmann 38fbee2e21 rar5: Improve varint handling
A varint field can actually have up to 10 bytes to resemble whole 64 bit
of a value. Use checked arithmetic to detect integer overflows.

Also, treat a varint which never has a byte without continuation bit as
faulty.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 19:03:22 +02:00
dependabot[bot] c52c7ed6fc CI: Bump the all-actions group with 6 updates
Bumps the all-actions group with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [acj/freebsd-firecracker-action](https://github.com/acj/freebsd-firecracker-action) | `0.10.3` | `0.10.4` |
| [actions/checkout](https://github.com/actions/checkout) | `7.0.0` | `7.0.1` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.37.0` | `4.37.1` |
| [github/codeql-action/autobuild](https://github.com/github/codeql-action) | `4.37.0` | `4.37.1` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.37.0` | `4.37.1` |
| [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) | `4.37.0` | `4.37.1` |


Updates `acj/freebsd-firecracker-action` from 0.10.3 to 0.10.4
- [Release notes](https://github.com/acj/freebsd-firecracker-action/releases)
- [Commits](https://github.com/acj/freebsd-firecracker-action/compare/53cfec625fd81cfb34160e6d9ec19c9d9baa8adf...0fe13161c7d388eed0570eac668e1ba8fc1f1e4e)

Updates `actions/checkout` from 7.0.0 to 7.0.1
- [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/9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0...3d3c42e5aac5ba805825da76410c181273ba90b1)

Updates `github/codeql-action/init` from 4.37.0 to 4.37.1
- [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/99df26d4f13ea111d4ec1a7dddef6063f76b97e9...7188fc363630916deb702c7fdcf4e481b751f97a)

Updates `github/codeql-action/autobuild` from 4.37.0 to 4.37.1
- [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/99df26d4f13ea111d4ec1a7dddef6063f76b97e9...7188fc363630916deb702c7fdcf4e481b751f97a)

Updates `github/codeql-action/analyze` from 4.37.0 to 4.37.1
- [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/99df26d4f13ea111d4ec1a7dddef6063f76b97e9...7188fc363630916deb702c7fdcf4e481b751f97a)

Updates `github/codeql-action/upload-sarif` from 4.37.0 to 4.37.1
- [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/99df26d4f13ea111d4ec1a7dddef6063f76b97e9...7188fc363630916deb702c7fdcf4e481b751f97a)

---
updated-dependencies:
- dependency-name: acj/freebsd-firecracker-action
  dependency-version: 0.10.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: github/codeql-action/autobuild
  dependency-version: 4.37.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.37.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 16:13:42 +00:00
Dustin L. Howett 3a8f29903f Merge pull request #3306 from stoeckmann/data 2026-07-20 10:25:52 -05:00
Tobias Stoeckmann 5a2330788e Generally use f for filter
If there is no good reason to deviate from the rule, always use "f" for
filter just as we use "a" for archive.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:51 +02:00
Tobias Stoeckmann 88df4c92f7 filter: Use f as filter variable name
- If filter is meant, use "f" instead of "self" or "filter".
- If bidder is meant, use "b" instead of "self".

Matches writer filter style.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:51 +02:00
Tobias Stoeckmann 12ba7fdf05 Unify filter data access names
Use "struct filter *filter" pattern, with filter being the name of the
filter. This matches the format parser pattern.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:51 +02:00
Tobias Stoeckmann 11b87598ce shar: Merge format setters
Clarify where the differences between the format setters are.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:51 +02:00
Tobias Stoeckmann 9f62f96798 Unify filter data handling
- Declare access variable at the beginning
- Remove unneeded cast

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:51 +02:00
Tobias Stoeckmann 6c3bab2480 Unify format data access names
It's generally the pattern "struct format *format". Unify for easier
readability.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:50 +02:00
Tobias Stoeckmann a631287e4c Unify format data handling
- Declare access variable at the beginning
- Remove unneeded cast (see warc parser, which never did it)
- Remove inline cast function
- Avoid unneeded brackets to unify style

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-20 08:55:25 +02:00
Tim Kientzle 4840347569 Merge pull request #616 from chenxiaolong/android-utf8
Force UTF-8 as the default charset on Android
2026-07-19 15:46:59 -07:00
Tim Kientzle 097119fc0f Merge pull request #3308 from datauwu/warc-reject-truncated-file-data
warc: reject truncated file data
2026-07-19 15:33:19 -07:00
Tim Kientzle e26d91cef1 Merge pull request #3309 from stoeckmann/write_huge
write: Correctly handle huge write requests
2026-07-19 15:28:53 -07:00
Tobias Stoeckmann 29dd9c909b write: Use uint64_t for __archive_write_nulls
Even though int64_t would be the correct data type because no more data
than INT64_MAX can be written, use the easier solution for format
writers for now.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-19 23:08:26 +02:00
Tobias Stoeckmann 0543fc1320 write: Do not write more than INT64_MAX bytes
Never try to write more than INT64_MAX bytes to avoid integer overflows.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-19 23:08:26 +02:00
Tobias Stoeckmann 91fa66073e tar: Verify that huge files are not written
Files which cannot fit into a stream should never return success, which
can happen due to truncation on 32 bit systems.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-19 23:07:44 +02:00
datauwu 402d829d2f warc: reject truncated file data
Return ARCHIVE_FATAL when EOF is reached before Content-Length.
2026-07-20 01:35:04 +08:00
datauwu 9fa66d8fe0 warc: test truncated file data
Verify that a body shorter than Content-Length is rejected.
2026-07-20 01:25:10 +08:00
Tim Kientzle e70bf490b8 Merge pull request #3301 from datauwu/zip-remove-redundant-helper
zip: remove redundant helper
2026-07-19 08:47:07 -07:00
Tim Kientzle cb550d2791 Merge pull request #3303 from datauwu/xar-write-fix-null-deref
xar: fix NULL dereference on allocation failure
2026-07-19 08:41:27 -07:00
Tim Kientzle ae8f0ccceb Merge pull request #3305 from datauwu/formats-various-cleanup
formats: simplify string handling
2026-07-19 08:39:55 -07:00
Tim Kientzle 30708c06c8 Merge pull request #3307 from stoeckmann/warc_digit
warc: Avoid `isdigit` in version number check
2026-07-19 08:03:20 -07:00
0xmrniko e548c99423 Guard RAR seek cursor before previous block lookup 2026-07-19 19:30:23 +05:30
0xmrniko f3d21565cb Add RAR seek_data cursor regression test 2026-07-19 19:30:18 +05:30
Tobias Stoeckmann 8827bc3016 warc: Avoid isdigit in version number check
The isdigit function is locale-dependent, which means that characters
outside of 0-9 range can return true here, e.g. "power of 2" for a few
locales on Windows.

Test for ASCII character range from '0' to '9' instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-19 13:46:06 +02:00
datauwu 888d25b754 pax: use memcpy for known-length path components
Use memcpy() for path components whose lengths are already known and
write the terminating null byte explicitly.

Cache the inserted component length instead of calculating it multiple
times while constructing the ustar pathname.
2026-07-19 18:01:44 +08:00
datauwu 70a04a84cc ar: use strrchr for member filenames
Replace the single-use basename helper with strrchr() and preserve the
existing rejection of pathnames ending in a slash.

Cache the member filename length to avoid repeated strlen() calls while
building and writing the archive header.
2026-07-19 18:01:44 +08:00
datauwu e9fcf44e02 rar: avoid rescanning converted path separators
Continue searching after each replaced backslash instead of restarting
from the beginning of the filename.

This avoids repeatedly scanning the already converted prefix.
2026-07-19 12:15:48 +08:00
datauwu 3cc1738058 lha: use memchr to validate filenames
Replace the bytewise filename scan with memchr() when checking for the
invalid 0xff byte.

The search remains bounded by the filename length.
2026-07-19 03:07:34 +08:00
datauwu 5cb553dbcb xar: fix NULL dereference on allocation failure
Check the allocation used to initialize cur_dirstr before accessing the
buffer.

Release the partially initialized strings, root entry, file registry,
and hardlink registry before returning ARCHIVE_FATAL.
2026-07-19 00:28:32 +08:00
datauwu 5a822798ff tar: fix UAF when reading GNU sparse headers
Copy the old GNU tar header before reading sparse extension blocks.

Those reads may replace or free the callback buffer backing the original
header. Use the copy when parsing the common header fields.
2026-07-18 23:31:40 +08:00
datauwu ee5715fc82 zip: remove redundant helper
Calculate the pathname length directly after validating the path.

The helper only wrapped strlen() and adjusted the length for directory
entries. Removing it keeps the calculation beside the validation and
reuses the existing file type value.
2026-07-18 19:19:45 +08:00
datauwu dc81f68c6f tar: add GNU sparse header buffer reuse test
Add a test archive that reuses one read buffer for every 512-byte block.

Reading the sparse extension overwrites the main GNU header. Check that
mode, uid, gid, and mtime still come from the original header.
2026-07-18 15:48:44 +08:00
Dustin L. Howett 84fbafad32 Merge pull request #3292 from datauwu/xar-fix-mem-leaks
xar: fix several memory leaks
2026-07-17 17:51:23 -05:00
Dustin L. Howett d141f661da Merge pull request #3297 from datauwu/archive-write-fix-uaf
archive_write: fix UAF when switching formats
2026-07-17 15:17:29 -05:00
Dustin L. Howett 10a7247810 Merge pull request #3294 from datauwu/bsdtar-fix-signed-overflow 2026-07-17 14:06:56 -05:00
Dustin L. Howett b85488c37a Merge pull request #3296 from stoeckmann/filter_writer 2026-07-17 14:04:59 -05:00
datauwu 17fc2be73a bsdtar: remove tar_i64toa()
Format integer values directly at each call site and remove the custom
integer formatter.

This handles the full signed integer range and preserves unsigned byte
counters.
2026-07-18 02:09:50 +08:00
datauwu 975ea4dbd9 archive_write: fix UAF when switching formats
Clear format state and callbacks after running the previous format
destructor so a failed replacement setup cannot leave stale pointers.

Also unregister previous GNU tar state and require ARCHIVE_STATE_NEW
before switching to GNU tar.
2026-07-18 01:27:25 +08:00
Dustin L. Howett 47d94d1f92 Merge pull request #3295 from stoeckmann/typos_2
Fix typos
2026-07-17 12:03:55 -05:00
Tobias Stoeckmann 66e5b3e5d7 uuencode: Fix typo
Add missing "encode" to magic error message.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-17 19:02:35 +02:00
Tobias Stoeckmann 727da55204 filter: Unify add_filter style
This makes it easier to spot differences, which might require more
attention.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-17 19:02:35 +02:00
Tobias Stoeckmann 421b6c267d filter: Check __archive_write_allocate_filter result
If allocation of filter fails, gracefully handle it instead of
eventually triggering a NULL pointer dereference.

Allocate the filter in last step, because it's rather difficult to
cleanly revert in case of error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-17 19:02:35 +02:00
Tobias Stoeckmann b2a38b8845 xz: Merge more common code into common_setup
Reduces complexity of individual functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-17 19:02:35 +02:00
Tobias Stoeckmann dfc4357a74 filter: Simplify archive handling
Use archive for magic check and logging directly.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-17 19:02:35 +02:00
Tobias Stoeckmann 42584eb62f compress: Allocate data while adding filter
This syncs compress write filter with other write filters.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-17 19:02:27 +02:00
datauwu 9c805a24ea archive_write: test format switch UAF cleanup
Test that unregistering 7-Zip and XAR clears format state and is safe
to repeat.

Also test switching from 7-Zip to GNU tar and selecting GNU tar again.
2026-07-18 00:05:01 +08:00