8131 Commits
Author SHA1 Message Date
Dustin L. Howett 4c7066dd98 Merge pull request #3227 from DHowett/windows-bsdtar-fix-upper-h-mode
win32: fix symlink mode 'H' (hybrid) in wildcard search
2026-07-07 10:23:19 -05:00
Tobias Stoeckmann 68ccc129a8 options: Use const char pointer where possible
If referenced strings are not modified, use const char pointer.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-07 17:16:01 +02:00
Dustin L. Howett f0af7530a1 Merge pull request #3258 from uchiha-bug-hunter/mtree-global-set-overread
mtree: fix out-of-bounds read in process_global_set
2026-07-07 09:26:38 -05:00
Dustin L. Howett 512675e432 Merge pull request #3262 from datauwu/zip-fix-oob-read
zip: fix 1-byte OOB read in Mac extension check
2026-07-07 09:25:11 -05:00
Dustin L. Howett 108381c805 Merge pull request #3263 from datauwu/bsdtar-fix-oob-read
bsdtar: fix 1-byte OOB read in substitution handling
2026-07-07 09:24:58 -05:00
Dustin L. Howett a6b6c50c3b Merge pull request #3260 from mmatuska/constify-fix
7-zip and rar5: add constifications missing in e150c2f41 (#3113)
2026-07-07 09:24:15 -05:00
Dustin L. Howett bcdda15a40 Merge pull request #3223 from DHowett/win32-o-excl
win32: prevent writing through a broken symlink in insecure mode
2026-07-07 09:17:28 -05:00
datauwu 0053ea743f bsdtar: fix 1-byte OOB read in substitution handling
The -s replacement scanner consumes a backslash and then reads the
escaped byte. If the replacement ends in one literal backslash, the loop
can advance past the terminating NUL and read one byte past the
allocated replacement buffer.

Stop scanning when a backslash is followed by the terminating NUL. The
final literal append then preserves the trailing backslash.
2026-07-07 21:58:54 +08:00
datauwu c81bc7eee8 zip: fix 1-byte OOB read in Mac extension check
The seekable ZIP reader checks whether __MACOSX/ entries are resource
fork entries by testing the basename prefix.

The existing guard used r - name, which is the basename offset from the
start of the filename, not the basename length. For a short basename such
as "__MACOSX/.", this could read one byte past the filename.

Check the remaining basename length before reading the resource fork prefix.
2026-07-07 20:36:24 +08:00
Martin Matuska 2610a79fd5 7-zip and rar5: add constifications missing in e150c2f41 (#3113) 2026-07-07 13:53:19 +02:00
Kaif Khan 5c61644fdb mtree: fix out-of-bounds read in process_global_set 2026-07-07 14:19:03 +05:30
R4mbb 82d44c4042 pax: handle all-slash pathnames in USTAR name splitting
When build_ustar_entry_name() trims trailing '/' characters and '/.'
path elements from a pathname made entirely of separators, filename_end
can be reduced all the way back to src.

Handle this root-like pathname case before attempting to locate the
filename component, and emit a root-like ustar name instead.

Add a regression test that writes and reads back a long all-slash pax
pathname.

Signed-off-by: R4mbb <yong010301@gmail.com>
2026-07-07 14:38:07 +09:00
Dustin L. Howett c16162083a Merge pull request #3253 from datauwu/tar-fix-oob 2026-07-06 21:00:05 -05:00
Dustin L. Howett dbb4e7f28d Merge pull request #3255 from datauwu/iso9660-fix-oob-read 2026-07-06 20:57:53 -05:00
datauwu 2f0e327d12 warc: fix pending data when skipping entries
Consume pending data before EOF and skip handling.

Then skip only the unread body bytes plus the WARC record separator.
This keeps the reader at the correct input position after an entry has
been partially or fully read.
2026-07-07 08:14:38 +08:00
datauwu bd0cae0be7 iso9660: fix 1-byte OOB read in directory scanning
read_children() checked the directory record length byte before ensuring
that the record pointer was still inside the current logical block.

If directory records exactly filled the final block, the next loop
condition could read one byte past the image buffer.

Check the remaining block length before reading the record length byte.
2026-07-07 08:07:59 +08:00
datauwu f93abd161e tar: fix 1-byte OOB read in number parsing
tar_atol_base_n() read the next byte before checking whether any bytes
remained. If a numeric field ended at the caller-provided boundary, this
caused a 1-byte OOB read while preparing the next digit range check.

Read each digit only while bytes remain.
2026-07-06 22:51:18 +08:00
Dustin L. Howett 51060e492b Merge pull request #3236 from uchiha-bug-hunter/acl-from-text-nl-overread
acl: fix over-read on empty field in archive_acl_from_text_nl
2026-07-06 09:29:59 -05:00
Tim Kientzle f4786afb10 Merge pull request #3250 from datauwu/tar-avoid-redundant-size
tar: avoid redundant Solaris ACL size parsing
2026-07-06 07:11:54 -07:00
Tim Kientzle d81b9f5582 Merge pull request #3252 from datauwu/tar-fix-oob-read
tar: fix 1-byte OOB read in SUN.holesdata parsing
2026-07-06 07:06:58 -07:00
datauwu 40b92de1de tar: fix 1-byte OOB read in SUN.holesdata parsing
header_pax_extension() passes PAX attribute values without the trailing
newline to pax_attribute(). The SUN.holesdata parser read one byte past
the supplied value when the last numeric field ended at the value
boundary.

Handle length == 0 before checking *e.
2026-07-06 21:51:15 +08:00
data 70bae9b796 tar: avoid redundant Solaris ACL size parsing
read_body_to_string() already consumes the extension body according to
the header size. Use the resulting string length instead of decoding the
size field again in header_Solaris_ACL().
2026-07-06 18:34:52 +08:00
datauwu 172e463c41 warc: add test for skipping after extraction
Add a test that extracts data from the first WARC resource record, then
moves to the second header.

This checks the bug where already-read entry data was not handled correctly
before skip handling.
2026-07-06 16:15:05 +08:00
Dustin L. Howett f0b9700384 Merge pull request #3246 from stoeckmann/cab_style
cab: Extend Huffman documentation
2026-07-06 00:04:31 -05:00
Dustin L. Howett 7b635176c5 Merge pull request #3244 from datauwu/warc-fix-write-past 2026-07-05 16:15:03 -05:00
Tobias Stoeckmann 59826c033e cab: Use strnlen if possible
Adjust cab_strnlen to match strnlen API and use system's strnlen if
available.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-05 21:46:12 +02:00
Tobias Stoeckmann 405cf62736 mtree: Fix custom strnlen API
If strnlen is not available, custom code is used. Make sure that the
custom code keeps premise of strnlen API for maximum compatibility.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-05 21:35:14 +02:00
Tim Kientzle f2f3eb9f50 Merge pull request #3245 from kientzle/kientzle-archive-read-failed-header-recovery
[Read core] Allow format handlers to FAIL a header read
2026-07-05 10:36:10 -07:00
Tobias Stoeckmann 07aca47167 cab: Extend Huffman documentation
Explain the algorithm and data structure involved in Huffman tree
handling as array. Hopefully simplifies upcoming code change
verifications.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-05 19:35:45 +02:00
Tim Kientzle 16d8156deb [Read core] Allow format readers to FAIL a header read
While investigating improvements to Zip's header reading,
I found	an overlooked case in the read core:  When a format
returned FAILED	for a header read (indicating that the entry
could not be read but that the archive as a whole is still valid),
the core silently converted that to FATAL, ending the archive
at that	point.

The change to the read core adds a new internal state "DATA_RECOVERY"
indicating that we're post-header (like the existing DATA state) but
that client requests to actually obtain data are not valid.
2026-07-05 10:12:33 -07:00
Tim Kientzle 0409837cb9 [Read core] Test handling of FAILED header reads
While investigating improvements to Zip's header reading,
I found	an overlooked case in the read core:  When a format
returned FAILED	for a header read (indicating that the entry
could not be read but that the archive as a whole is still valid),
the core silently converted that to FATAL, ending the archive
at that	point.

Two formats already returned FAILED for	certain	header issues:
Zip and	LHA both indicated unreadable symlink entries in this way,
which should allow the rest of the archive to continue being read.
New tests here verify that we can now continue reading past
such entries, and that clients who ignore the FAILED result
get the	same FATAL handling as other API misuse.
2026-07-05 10:11:50 -07:00
data 80cda1e17e warc: track remaining entry bytes when writing data
The WARC writer capped each data write against the full declared entry
size, but never reduced that value after accepting data. As a result,
repeated write calls could emit more bytes than the WARC Content-Length.

Track the remaining byte count for the current regular-file entry and
decrement it after each successful write. Further writes are then
clamped to the remaining length and return zero once the entry is full.
2026-07-06 00:31:53 +08:00
data ab1de8f3bc warc: test repeated writes past Content-Length
Verify that a WARC entry does not accept bytes after its declared
Content-Length has already been written.
2026-07-06 00:28:38 +08:00
Tim Kientzle f7965ac947 Merge pull request #3242 from datauwu/zip-basic-support-0x000d
zip: read PKWARE Unix extra field metadata
2026-07-05 08:38:11 -07:00
Tobias Stoeckmann 3ad6bb89a9 cab: Do not nest struct definitions
This complies with other C source files of format parsers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2026-07-05 17:27:14 +02:00
Kaif Khan 70e4b8c511 acl: fix over-read on empty field in archive_acl_from_text_nl
archive_acl_from_text_nl() parses ACL text from a pointer and a length
and does not require a NUL terminator; the tar reader passes a
__archive_read_ahead() window of exactly value_length bytes for
SCHILY.acl.access/.default/.ace.  When an entry is empty (a
whitespace-only value, or trailing whitespace after a valid entry)
next_field() consumes the rest of the buffer as whitespace and leaves
field[0].start one past the end, which the '#'-comment probe then
dereferences.  Capture the buffer end and skip the entry when its first
field starts there.  The wide archive_acl_from_text_w is NUL terminated
and unaffected.
2026-07-05 13:39:58 +05:30
Kaif Khan 18f5209e48 acl: add test_acl_from_text_overread regression test
Drives archive_acl_from_text_nl() with exact-length, non-NUL-terminated
buffers whose first field is only whitespace, covering the empty-entry
and trailing-whitespace cases.  Allow the test to include
archive_acl_private.h via __LIBARCHIVE_TEST.
2026-07-05 13:39:52 +05:30
datauwu 467d31b0cf zip: read PKWARE Unix extra field metadata
Read the fixed metadata prefix of the PKWARE Unix extra field 0x000d.

The fixed portion contains atime, mtime, uid, and gid values. Require
the full 12-byte prefix before reading it, and leave the variable-length
data field unsupported for now.
2026-07-05 13:27:29 +08:00
datauwu 9a2087f9d7 zip: test PKWARE Unix extra field
Add a test for the PKWARE Unix extra field 0x000d.

The fixture stores a regular file with the 12-byte fixed metadata
prefix in both the local header and central directory. The test checks
that the ZIP reader exposes mtime, atime, uid, and gid metadata for
seekable and streaming reads.
2026-07-05 13:22:03 +08:00
Tim Kientzle d21fdc9f84 Merge pull request #3240 from kientzle/kientzle-zip-uncompressed-size-exact-check
[Zip] Reject archives if the 32-bit size field is not correct
2026-07-04 22:06:35 -07:00
Dustin L. Howett 3c3ec69d44 Merge pull request #3232 from kientzle/kientzle-read-data-into-fd-size-boundary
[Write] Truncate write-to-fd at the declared entry size
2026-07-04 15:08:23 -05:00
Dustin L. Howett afc33dfeb4 Merge pull request #3219 from DHowett/custom-clang-in-ci
ci: add a new Lint step that uses a custom-built linter
2026-07-04 14:57:14 -05:00
Dustin L. Howett 3151a76b1e Merge pull request #3237 from datauwu/tar-avoid-redundant-mode
tar: avoid redundant mode parsing
2026-07-04 14:56:02 -05:00
Dustin L. Howett cebab49b99 Merge pull request #3233 from stoeckmann/archive_entry_new2
Check `archive_entry_new2` return value
2026-07-04 14:51:49 -05:00
Dustin L. Howett 0cb18445d3 Merge pull request #3234 from stoeckmann/raw_oflow
raw: Properly treat huge inputs
2026-07-04 14:51:31 -05:00
Dustin L. Howett e19d93fe22 lint: compile la-lint and use in place of clang-tidy 2026-07-04 14:42:27 -05:00
Dustin L. Howett 942984fd7d Merge commit '25ef914386252adbf67d07d6c5bf018dfcbe34a9' as 'build/la-lint' 2026-07-04 14:42:27 -05:00
Dustin L. Howett 25ef914386 Squashed 'build/la-lint/' content from commit 66dbe023
git-subtree-dir: build/la-lint
git-subtree-split: 66dbe023892df333ae794f6004553ff0a3d32275
2026-07-04 14:42:27 -05:00
Dustin L. Howett c0f58c7b34 build: add a new "lint" workflow that runs clang-tidy 2026-07-04 14:42:26 -05:00
Dustin L. Howett 89efbd80de build: add ENABLE_CLANG_TIDY and CLANG_TIDY_PATH 2026-07-04 14:42:26 -05:00