]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
2 weeks agocpio: fix read-ahead pointer lifetime issue 3277/head
datauwu [Sat, 11 Jul 2026 04:06:46 +0000 (12:06 +0800)] 
cpio: fix read-ahead pointer lifetime issue

Cache the CPIO trailer-name check before consuming the pathname
buffer.

The reader kept a pointer returned by __archive_read_ahead() and used
it after __archive_read_consume(), and after possible symlink body
processing. Read-ahead pointers are views into libarchive input buffers
and should not be relied on after the associated bytes are consumed.

Store the TRAILER!!! decision while the pathname buffer is still valid,
then use the saved boolean after the remaining header handling.

2 weeks agoMerge pull request #3274 from datauwu/warc-fix-oob-read
Dustin L. Howett [Fri, 10 Jul 2026 21:39:15 +0000 (16:39 -0500)] 
Merge pull request #3274 from datauwu/warc-fix-oob-read

warc: parse Content-Length as a bounded field

2 weeks agowarc: parse Content-Length as a bounded field 3274/head
datauwu [Fri, 10 Jul 2026 16:07:55 +0000 (00:07 +0800)] 
warc: parse Content-Length as a bounded field

Parse Content-Length only up to the located end-of-line instead of
passing a bounded header field to strtol(). Use int64_t for the parsed
entry size, ASCII digit checks, and checked arithmetic while accumulating
the value.

2 weeks agoMerge pull request #3275 from datauwu/fix-several-left-shift-ub
Tim Kientzle [Fri, 10 Jul 2026 17:29:24 +0000 (10:29 -0700)] 
Merge pull request #3275 from datauwu/fix-several-left-shift-ub

libarchive: fix left-shift UB in several places

2 weeks agotests: fix signed left-shift UB in fuzz consumer 3275/head
datauwu [Fri, 10 Jul 2026 13:35:35 +0000 (21:35 +0800)] 
tests: fix signed left-shift UB in fuzz consumer

Fix i64 construction by using a uint64_t accumulator.

2 weeks agopax: fix signed-char left-shift UB in base64 encoder
datauwu [Fri, 10 Jul 2026 13:35:35 +0000 (21:35 +0800)] 
pax: fix signed-char left-shift UB in base64 encoder

Fix base64 shifts by casting input bytes to unsigned.

2 weeks agorar: fix signed left-shift UB in audio filter
datauwu [Fri, 10 Jul 2026 13:35:35 +0000 (21:35 +0800)] 
rar: fix signed left-shift UB in audio filter

Fix signed audio delta scaling by using multiplication.

2 weeks ago7zip: fix negative shift count in x86 BCJ filter
datauwu [Fri, 10 Jul 2026 13:35:35 +0000 (21:35 +0800)] 
7zip: fix negative shift count in x86 BCJ filter

Fix the previous-position shift count before updating the mask.

2 weeks agoMerge pull request #3257 from R4mbb/fix-pax-all-slash-pathname
Dustin L. Howett [Thu, 9 Jul 2026 15:53:22 +0000 (10:53 -0500)] 
Merge pull request #3257 from R4mbb/fix-pax-all-slash-pathname

pax: handle all-slash pathnames in USTAR name splitting

2 weeks agoMerge pull request #3256 from stoeckmann/cab_integers
Dustin L. Howett [Thu, 9 Jul 2026 15:03:45 +0000 (10:03 -0500)] 
Merge pull request #3256 from stoeckmann/cab_integers

cab: Refactor data types + extend huffman tables to 16 bit if needed

2 weeks agocab: Grow pre-tree Huffman table if needed 3256/head
Tobias Stoeckmann [Mon, 6 Jul 2026 17:06:45 +0000 (19:06 +0200)] 
cab: Grow pre-tree Huffman table if needed

The standard has no fixed 10 bit limit. Instead, a pre-tree could
contain up to 16 bit codes, although this is very unlikely.

Grow the table if needed.

While at it, clarify now that max_bits are actually lookup_bits.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Add large LZX pre-tree test
Tobias Stoeckmann [Wed, 8 Jul 2026 18:25:49 +0000 (20:25 +0200)] 
cab: Add large LZX pre-tree test

If a pre-tree is larger than 10 bit, libarchive fails to read the data.
According to spec, up to 16 bit are valid.

Example file provided by Duncan Horn. Thanks a lot!

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Clarify LZX/Huffman bit handling
Tobias Stoeckmann [Mon, 6 Jul 2026 16:59:30 +0000 (18:59 +0200)] 
cab: Clarify LZX/Huffman bit handling

- Huffman operations are up to 16 bit, thus uint16_t
- LZX itself can handle up to 32 bit, thus uint32_t
- Memory sizes are size_t

Otherwise:

- Use uint8_t to show where bit lengths are stored
- Use int to clarify that a status is stored

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Remove check in lzx_make_huffman_table
Tobias Stoeckmann [Mon, 6 Jul 2026 16:43:36 +0000 (18:43 +0200)] 
cab: Remove check in lzx_make_huffman_table

The check against table size is redundant since Kraft's inequality
already verified that this operation cannot exceed table size anymore.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Use correct limit in lzx_make_huffman_table
Tobias Stoeckmann [Mon, 6 Jul 2026 16:31:47 +0000 (18:31 +0200)] 
cab: Use correct limit in lzx_make_huffman_table

The table size is in bytes, but bitlen must be checked against maximum
bit length allowed.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Clarify lzx_decode_huffman signature
Tobias Stoeckmann [Mon, 6 Jul 2026 16:20:57 +0000 (18:20 +0200)] 
cab: Clarify lzx_decode_huffman signature

No more than 16 bits shall ever be supplied for a table lookup.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Adjust lzx_read_bitlen API
Tobias Stoeckmann [Mon, 6 Jul 2026 16:15:51 +0000 (18:15 +0200)] 
cab: Adjust lzx_read_bitlen API

Use 0 as marker for maximum symbol count to be able to eventually switch
to another data type.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Clear lookup table in lzx_huffman_init
Tobias Stoeckmann [Mon, 6 Jul 2026 16:02:55 +0000 (18:02 +0200)] 
cab: Clear lookup table in lzx_huffman_init

This step is not actually needed, but will prevent static analysis
warnings that values might exist which have never been initialized.

"Invalid" values only exist outside of the addressable area, which can
happen if maximum code bit length is smaller than table bit length.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Clarify what "len_size" is
Tobias Stoeckmann [Mon, 6 Jul 2026 15:56:43 +0000 (17:56 +0200)] 
cab: Clarify what "len_size" is

It's actually the amount of symbols/codes in Huffman tree. Clarify it by
using the field name symbol_count instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Use ARCHIVE_* values with lzx functions
Tobias Stoeckmann [Mon, 6 Jul 2026 15:46:59 +0000 (17:46 +0200)] 
cab: Use ARCHIVE_* values with lzx functions

Some lzx functions reverse the generic logic of 0 being success and
anything else being an error. It's debatable from a boolean point of
view but use the regular ARCHIVE_OK in case of success, which is 0.

Unifies with other lzx functions and general idea of libarchive
functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Fix Kraft's inequality check
Tobias Stoeckmann [Mon, 6 Jul 2026 15:38:52 +0000 (17:38 +0200)] 
cab: Fix Kraft's inequality check

We really have to check if Kraft's inequality is 1 (in our case it's
0x10000) or 0 for an empty tree. Anything else is an error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Simplify lzx_decode_huffman
Tobias Stoeckmann [Mon, 6 Jul 2026 15:25:59 +0000 (17:25 +0200)] 
cab: Simplify lzx_decode_huffman

As long as the given index is in range of the table, the previous
creation of the lookup table takes care that all elements are valid.

This is a left over of actual tree removal done in commit
c253f0aae9ac86a617b4f814137e07757df72391.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agocab: Remove inline keyword
Tobias Stoeckmann [Mon, 6 Jul 2026 15:14:31 +0000 (17:14 +0200)] 
cab: Remove inline keyword

Most if not all compilers today understand inline, but it's also just a
hint. Static functions will be inlined if it's worth it from compiler
perspective and inline functions will be still functions, too.

Remove it and let compilers decide. Increases portability for very old
compilers which cannot handle it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoMerge pull request #3259 from uchiha-bug-hunter/7zip-bound-header-counts
Tobias Stoeckmann [Thu, 9 Jul 2026 06:34:32 +0000 (08:34 +0200)] 
Merge pull request #3259 from uchiha-bug-hunter/7zip-bound-header-counts

7zip: bound folder and stream counts before allocating

2 weeks agoMerge pull request #3266 from datauwu/pax-fix-oob-read
Dustin L. Howett [Thu, 9 Jul 2026 03:26:06 +0000 (22:26 -0500)] 
Merge pull request #3266 from datauwu/pax-fix-oob-read

pax: fix 1-byte OOB read in sparse name building

2 weeks agoMerge pull request #3267 from datauwu/iso9660-fix-oob
Dustin L. Howett [Thu, 9 Jul 2026 03:20:50 +0000 (22:20 -0500)] 
Merge pull request #3267 from datauwu/iso9660-fix-oob

iso9660: fix 1-byte OOB read in iso-level option

2 weeks agoMerge pull request #3268 from uchiha-bug-hunter/best-effort-strncat-overread
Dustin L. Howett [Thu, 9 Jul 2026 03:19:43 +0000 (22:19 -0500)] 
Merge pull request #3268 from uchiha-bug-hunter/best-effort-strncat-overread

archive_string: bound best_effort_strncat_in_locale to length

2 weeks agoarchive_string: bound best_effort_strncat_in_locale to length 3268/head
Kaif Khan [Wed, 8 Jul 2026 16:40:27 +0000 (22:10 +0530)] 
archive_string: bound best_effort_strncat_in_locale to length

remaining was set to length but never decremented, so the loop only stopped at a NUL and read past fields passed without a trailing NUL (a read_ahead window sized by mbsnbytes). Decrement per byte and check the count before dereferencing *itp.

2 weeks agoarchive_string: add test for best-effort converter over-read
Kaif Khan [Wed, 8 Jul 2026 16:40:19 +0000 (22:10 +0530)] 
archive_string: add test for best-effort converter over-read

Drives the best-effort converter (charset iconv cannot open) through
archive_strncpy_l with a length-delimited buffer: once with trailing
non-NUL bytes after the declared length and once with an exact-length
heap allocation with no trailing NUL. Fails under ASan before the fix.

3 weeks agoiso9660: fix 1-byte OOB read in iso-level option 3267/head
datauwu [Wed, 8 Jul 2026 12:24:33 +0000 (20:24 +0800)] 
iso9660: fix 1-byte OOB read in iso-level option

iso9660_options() checks the second byte of the iso-level option value
before checking that the first byte contains a valid ISO level.

For an empty option value such as iso9660:iso-level=,
archive_write_set_options() passes a value pointer to the terminating NUL
byte of the duplicated options string. Reading value[1] then reads one byte
past that heap allocation.

Check value[0] before reading value[1]. This keeps the same accepted values
while rejecting the empty value without reading past the option buffer.

3 weeks agopax: fix 1-byte OOB read in sparse name building 3266/head
datauwu [Wed, 8 Jul 2026 10:10:27 +0000 (18:10 +0800)] 
pax: fix 1-byte OOB read in sparse name building

The GNU sparse name builder trims trailing slash and /. components before
building the synthetic ustar entry name. If the sparse pathname is fully
pruned, the effective source length becomes zero and build_ustar_entry_name()
reads one byte before the pathname buffer.

Handle the all-pruned pathname case before calling the ustar name builder.
The synthetic name then preserves the root-directory case.

3 weeks ago7zip: bound NumFolders before allocating folders array 3259/head
Kaif Khan [Tue, 7 Jul 2026 09:56:35 +0000 (15:26 +0530)] 
7zip: bound NumFolders before allocating folders array

3 weeks agoMerge pull request #3265 from stoeckmann/ckd_alloc
Dustin L. Howett [Tue, 7 Jul 2026 18:49:14 +0000 (13:49 -0500)] 
Merge pull request #3265 from stoeckmann/ckd_alloc

Check size arithmetic before memory allocations

3 weeks agoMerge pull request #3214 from uchiha-bug-hunter/tar-sun-holesdata-overread
Dustin L. Howett [Tue, 7 Jul 2026 18:45:47 +0000 (13:45 -0500)] 
Merge pull request #3214 from uchiha-bug-hunter/tar-sun-holesdata-overread

tar: add regression test for SUN.holesdata sparse map ending on a digit

3 weeks agotar: add test for SUN.holesdata sparse map ending on a digit 3214/head
Kaif Khan [Thu, 2 Jul 2026 06:54:47 +0000 (12:24 +0530)] 
tar: add test for SUN.holesdata sparse map ending on a digit

Read a Solaris pax entry whose SUN.holesdata value ends right after its
final decimal offset (no trailing space), which is the shape of every
valid map. The 1536-byte file has data at [0,512) and [1024,1536) with a
hole between them, so archive_entry_sparse must report exactly those two
data blocks. This pins the parser's loop-termination behavior for the
common case where the run consumes all value_length bytes.

3 weeks agoMerge pull request #3220 from DHowett/fix-assertions-lstat
Tobias Stoeckmann [Tue, 7 Jul 2026 17:28:21 +0000 (19:28 +0200)] 
Merge pull request #3220 from DHowett/fix-assertions-lstat

test: make Windows file assertions act like lstat

3 weeks agoCheck size arithmetic before memory allocations 3265/head
Tobias Stoeckmann [Tue, 7 Jul 2026 15:45:56 +0000 (17:45 +0200)] 
Check size arithmetic before memory allocations

Make sure that multiplications do not overflow (or if they overflow,
handle them properly).

This also means that proper data type size_t instead of int is used.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoMerge pull request #3249 from datauwu/warc-fix-pending-data
Dustin L. Howett [Tue, 7 Jul 2026 15:47:10 +0000 (10:47 -0500)] 
Merge pull request #3249 from datauwu/warc-fix-pending-data

warc: fix pending data when skipping entries

3 weeks agotest: make Windows file assertions act like lstat 3220/head
Dustin L. Howett [Wed, 1 Jul 2026 17:24:09 +0000 (12:24 -0500)] 
test: make Windows file assertions act like lstat

I've removed our lstat shim and replaced all uses with my_GetFileInformationByName.

3 weeks agoMerge pull request #3227 from DHowett/windows-bsdtar-fix-upper-h-mode
Dustin L. Howett [Tue, 7 Jul 2026 15:23:19 +0000 (10:23 -0500)] 
Merge pull request #3227 from DHowett/windows-bsdtar-fix-upper-h-mode

win32: fix symlink mode 'H' (hybrid) in wildcard search

3 weeks agoMerge pull request #3258 from uchiha-bug-hunter/mtree-global-set-overread
Dustin L. Howett [Tue, 7 Jul 2026 14:26:38 +0000 (09:26 -0500)] 
Merge pull request #3258 from uchiha-bug-hunter/mtree-global-set-overread

mtree: fix out-of-bounds read in process_global_set

3 weeks agoMerge pull request #3262 from datauwu/zip-fix-oob-read
Dustin L. Howett [Tue, 7 Jul 2026 14:25:11 +0000 (09:25 -0500)] 
Merge pull request #3262 from datauwu/zip-fix-oob-read

zip: fix 1-byte OOB read in Mac extension check

3 weeks agoMerge pull request #3263 from datauwu/bsdtar-fix-oob-read
Dustin L. Howett [Tue, 7 Jul 2026 14:24:58 +0000 (09:24 -0500)] 
Merge pull request #3263 from datauwu/bsdtar-fix-oob-read

bsdtar: fix 1-byte OOB read in substitution handling

3 weeks agoMerge pull request #3260 from mmatuska/constify-fix
Dustin L. Howett [Tue, 7 Jul 2026 14:24:15 +0000 (09:24 -0500)] 
Merge pull request #3260 from mmatuska/constify-fix

7-zip and rar5: add constifications missing in e150c2f41 (#3113)

3 weeks agoMerge pull request #3223 from DHowett/win32-o-excl
Dustin L. Howett [Tue, 7 Jul 2026 14:17:28 +0000 (09:17 -0500)] 
Merge pull request #3223 from DHowett/win32-o-excl

win32: prevent writing through a broken symlink in insecure mode

3 weeks agobsdtar: fix 1-byte OOB read in substitution handling 3263/head
datauwu [Tue, 7 Jul 2026 13:58:54 +0000 (21:58 +0800)] 
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.

3 weeks agozip: fix 1-byte OOB read in Mac extension check 3262/head
datauwu [Tue, 7 Jul 2026 12:36:24 +0000 (20:36 +0800)] 
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.

3 weeks ago7-zip and rar5: add constifications missing in e150c2f41 (#3113) 3260/head
Martin Matuska [Tue, 7 Jul 2026 11:52:29 +0000 (13:52 +0200)] 
7-zip and rar5: add constifications missing in e150c2f41 (#3113)

3 weeks agomtree: fix out-of-bounds read in process_global_set 3258/head
Kaif Khan [Tue, 7 Jul 2026 08:49:03 +0000 (14:19 +0530)] 
mtree: fix out-of-bounds read in process_global_set

3 weeks agopax: handle all-slash pathnames in USTAR name splitting 3257/head
R4mbb [Tue, 7 Jul 2026 05:38:07 +0000 (14:38 +0900)] 
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>
3 weeks agoMerge pull request #3253 from datauwu/tar-fix-oob
Dustin L. Howett [Tue, 7 Jul 2026 02:00:05 +0000 (21:00 -0500)] 
Merge pull request #3253 from datauwu/tar-fix-oob

3 weeks agoMerge pull request #3255 from datauwu/iso9660-fix-oob-read
Dustin L. Howett [Tue, 7 Jul 2026 01:57:53 +0000 (20:57 -0500)] 
Merge pull request #3255 from datauwu/iso9660-fix-oob-read

3 weeks agowarc: fix pending data when skipping entries 3249/head
datauwu [Mon, 6 Jul 2026 08:15:05 +0000 (16:15 +0800)] 
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.

3 weeks agoiso9660: fix 1-byte OOB read in directory scanning 3255/head
datauwu [Mon, 6 Jul 2026 16:37:30 +0000 (00:37 +0800)] 
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.

3 weeks agotar: fix 1-byte OOB read in number parsing 3253/head
datauwu [Mon, 6 Jul 2026 14:51:18 +0000 (22:51 +0800)] 
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.

3 weeks agoMerge pull request #3236 from uchiha-bug-hunter/acl-from-text-nl-overread
Dustin L. Howett [Mon, 6 Jul 2026 14:29:59 +0000 (09:29 -0500)] 
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

3 weeks agoMerge pull request #3250 from datauwu/tar-avoid-redundant-size
Tim Kientzle [Mon, 6 Jul 2026 14:11:54 +0000 (07:11 -0700)] 
Merge pull request #3250 from datauwu/tar-avoid-redundant-size

tar: avoid redundant Solaris ACL size parsing

3 weeks agoMerge pull request #3252 from datauwu/tar-fix-oob-read
Tim Kientzle [Mon, 6 Jul 2026 14:06:58 +0000 (07:06 -0700)] 
Merge pull request #3252 from datauwu/tar-fix-oob-read

tar: fix 1-byte OOB read in SUN.holesdata parsing

3 weeks agotar: fix 1-byte OOB read in SUN.holesdata parsing 3252/head
datauwu [Mon, 6 Jul 2026 13:51:15 +0000 (21:51 +0800)] 
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.

3 weeks agotar: avoid redundant Solaris ACL size parsing 3250/head
data [Mon, 6 Jul 2026 10:34:52 +0000 (18:34 +0800)] 
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().

3 weeks agowarc: add test for skipping after extraction
datauwu [Mon, 6 Jul 2026 08:15:05 +0000 (16:15 +0800)] 
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.

3 weeks agoMerge pull request #3246 from stoeckmann/cab_style
Dustin L. Howett [Mon, 6 Jul 2026 05:04:31 +0000 (00:04 -0500)] 
Merge pull request #3246 from stoeckmann/cab_style

cab: Extend Huffman documentation

3 weeks agoMerge pull request #3244 from datauwu/warc-fix-write-past
Dustin L. Howett [Sun, 5 Jul 2026 21:15:03 +0000 (16:15 -0500)] 
Merge pull request #3244 from datauwu/warc-fix-write-past

3 weeks agoMerge pull request #3245 from kientzle/kientzle-archive-read-failed-header-recovery
Tim Kientzle [Sun, 5 Jul 2026 17:36:10 +0000 (10:36 -0700)] 
Merge pull request #3245 from kientzle/kientzle-archive-read-failed-header-recovery

[Read core] Allow format handlers to FAIL a header read

3 weeks agocab: Extend Huffman documentation 3246/head
Tobias Stoeckmann [Sun, 5 Jul 2026 17:22:00 +0000 (19:22 +0200)] 
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>
3 weeks ago[Read core] Allow format readers to FAIL a header read 3245/head
Tim Kientzle [Sun, 5 Jul 2026 17:12:33 +0000 (10:12 -0700)] 
[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.

3 weeks ago[Read core] Test handling of FAILED header reads
Tim Kientzle [Sun, 5 Jul 2026 17:11:50 +0000 (10:11 -0700)] 
[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.

3 weeks agowarc: track remaining entry bytes when writing data 3244/head
data [Sun, 5 Jul 2026 16:31:53 +0000 (00:31 +0800)] 
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.

3 weeks agowarc: test repeated writes past Content-Length
data [Sun, 5 Jul 2026 16:28:38 +0000 (00:28 +0800)] 
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.

3 weeks agoMerge pull request #3242 from datauwu/zip-basic-support-0x000d
Tim Kientzle [Sun, 5 Jul 2026 15:38:11 +0000 (08:38 -0700)] 
Merge pull request #3242 from datauwu/zip-basic-support-0x000d

zip: read PKWARE Unix extra field metadata

3 weeks agocab: Do not nest struct definitions
Tobias Stoeckmann [Sun, 5 Jul 2026 15:27:14 +0000 (17:27 +0200)] 
cab: Do not nest struct definitions

This complies with other C source files of format parsers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoacl: fix over-read on empty field in archive_acl_from_text_nl 3236/head
Kaif Khan [Sun, 5 Jul 2026 08:09:58 +0000 (13:39 +0530)] 
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.

3 weeks agoacl: add test_acl_from_text_overread regression test
Kaif Khan [Sun, 5 Jul 2026 08:09:52 +0000 (13:39 +0530)] 
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.

3 weeks agozip: read PKWARE Unix extra field metadata 3242/head
datauwu [Sun, 5 Jul 2026 05:22:03 +0000 (13:22 +0800)] 
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.

3 weeks agozip: test PKWARE Unix extra field
datauwu [Sun, 5 Jul 2026 05:22:03 +0000 (13:22 +0800)] 
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.

3 weeks agoMerge pull request #3240 from kientzle/kientzle-zip-uncompressed-size-exact-check
Tim Kientzle [Sun, 5 Jul 2026 05:06:35 +0000 (22:06 -0700)] 
Merge pull request #3240 from kientzle/kientzle-zip-uncompressed-size-exact-check

[Zip] Reject archives if the 32-bit size field is not correct

3 weeks agoMerge pull request #3232 from kientzle/kientzle-read-data-into-fd-size-boundary
Dustin L. Howett [Sat, 4 Jul 2026 20:08:23 +0000 (15:08 -0500)] 
Merge pull request #3232 from kientzle/kientzle-read-data-into-fd-size-boundary

[Write] Truncate write-to-fd at the declared entry size

3 weeks agoMerge pull request #3219 from DHowett/custom-clang-in-ci
Dustin L. Howett [Sat, 4 Jul 2026 19:57:14 +0000 (14:57 -0500)] 
Merge pull request #3219 from DHowett/custom-clang-in-ci

ci: add a new Lint step that uses a custom-built linter

3 weeks agoMerge pull request #3237 from datauwu/tar-avoid-redundant-mode
Dustin L. Howett [Sat, 4 Jul 2026 19:56:02 +0000 (14:56 -0500)] 
Merge pull request #3237 from datauwu/tar-avoid-redundant-mode

 tar: avoid redundant mode parsing

3 weeks agoMerge pull request #3233 from stoeckmann/archive_entry_new2
Dustin L. Howett [Sat, 4 Jul 2026 19:51:49 +0000 (14:51 -0500)] 
Merge pull request #3233 from stoeckmann/archive_entry_new2

Check `archive_entry_new2` return value

3 weeks agoMerge pull request #3234 from stoeckmann/raw_oflow
Dustin L. Howett [Sat, 4 Jul 2026 19:51:31 +0000 (14:51 -0500)] 
Merge pull request #3234 from stoeckmann/raw_oflow

raw: Properly treat huge inputs

3 weeks agolint: compile la-lint and use in place of clang-tidy 3219/head
Dustin L. Howett [Wed, 1 Jul 2026 15:05:37 +0000 (10:05 -0500)] 
lint: compile la-lint and use in place of clang-tidy

3 weeks agoMerge commit '25ef914386252adbf67d07d6c5bf018dfcbe34a9' as 'build/la-lint'
Dustin L. Howett [Sat, 4 Jul 2026 19:42:27 +0000 (14:42 -0500)] 
Merge commit '25ef914386252adbf67d07d6c5bf018dfcbe34a9' as 'build/la-lint'

3 weeks agoSquashed 'build/la-lint/' content from commit 66dbe023
Dustin L. Howett [Sat, 4 Jul 2026 19:42:27 +0000 (14:42 -0500)] 
Squashed 'build/la-lint/' content from commit 66dbe023

git-subtree-dir: build/la-lint
git-subtree-split: 66dbe023892df333ae794f6004553ff0a3d32275

3 weeks agobuild: add a new "lint" workflow that runs clang-tidy
Dustin L. Howett [Tue, 30 Jun 2026 14:48:44 +0000 (09:48 -0500)] 
build: add a new "lint" workflow that runs clang-tidy

3 weeks agobuild: add ENABLE_CLANG_TIDY and CLANG_TIDY_PATH
Dustin L. Howett [Tue, 30 Jun 2026 14:43:53 +0000 (09:43 -0500)] 
build: add ENABLE_CLANG_TIDY and CLANG_TIDY_PATH

3 weeks agoMerge pull request #3239 from datauwu/warc-require-size
Dustin L. Howett [Sat, 4 Jul 2026 19:24:22 +0000 (14:24 -0500)] 
Merge pull request #3239 from datauwu/warc-require-size

3 weeks agowarc: require file size before writing header 3239/head
datauwu [Sat, 4 Jul 2026 17:26:57 +0000 (01:26 +0800)] 
warc: require file size before writing header

WARC records require a known Content-Length. Reject regular file
entries without a valid size instead of treating them as zero.
Avoid casting archive_entry_size() through size_t before storing it in
the uint64_t WARC Content-Length field, since that can truncate large
sizes on 32-bit platforms.

3 weeks agoMerge pull request #3238 from stoeckmann/cpio_ioflow
Tim Kientzle [Sat, 4 Jul 2026 17:43:37 +0000 (10:43 -0700)] 
Merge pull request #3238 from stoeckmann/cpio_ioflow

cpio: Prevent signed integer overflow

3 weeks agowarc: test missing file size handling
datauwu [Sat, 4 Jul 2026 17:26:57 +0000 (01:26 +0800)] 
warc: test missing file size handling

Add coverage for WARC entries without a known size. The writer
must reject these entries because WARC requires Content-Length.

3 weeks agocpio: Prevent signed integer overflow 3238/head
Tobias Stoeckmann [Sat, 4 Jul 2026 17:06:52 +0000 (19:06 +0200)] 
cpio: Prevent signed integer overflow

If enough bytes have to be skipped, a signed integer overflow could
occur (most realistically on 32 bit systems). Use an unsigned type,
which could still overflow but has only negative impact on diagnostic
warning message.

Follow up of 02fa05675fdf8054ae0dd73df8c5264e61f3a068 but this time for
function find_newc_header.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
3 weeks agoUpdate libarchive/archive_read_data_into_fd.c 3232/head
Tim Kientzle [Sat, 4 Jul 2026 16:48:31 +0000 (09:48 -0700)] 
Update libarchive/archive_read_data_into_fd.c

Co-authored-by: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>
3 weeks agoMerge pull request #3231 from datauwu/7zip-skip-archiveproperties
Tobias Stoeckmann [Sat, 4 Jul 2026 07:56:23 +0000 (09:56 +0200)] 
Merge pull request #3231 from datauwu/7zip-skip-archiveproperties

7zip: skip ArchiveProperties payload data

3 weeks agopax: remove redundant hardlink size assignment 3237/head
datauwu [Sat, 4 Jul 2026 05:57:33 +0000 (13:57 +0800)] 
pax: remove redundant hardlink size assignment

archive_write_pax_header() set hardlink entries to size zero for the
restricted pax format, then immediately set all hardlink entries to size
zero again.

Remove the narrower check because it is fully subsumed by the following
hardlink check.

No functional change intended.

3 weeks agotar: avoid parsing mode field twice
datauwu [Sat, 4 Jul 2026 05:57:32 +0000 (13:57 +0800)] 
tar: avoid parsing mode field twice

header_common() parsed the tar mode field once when setting the file
type and again when setting permissions. Cache the parsed value and reuse
it for both setters.

archive_entry_set_filetype() and archive_entry_set_perm() already mask
the relevant bits, so passing the full header mode preserves behavior.
The permission-set guard is unchanged.

No functional change intended.

3 weeks agoFix the test failure
Tim Kientzle [Sat, 4 Jul 2026 04:52:27 +0000 (21:52 -0700)] 
Fix the test failure

This was originally developed without the Zip fix from #3230.
Since that's been merged, we need to adjust the expectations here
a bit.

3 weeks agoRework size-overrun check to avoid arithmetic errors
Tim Kientzle [Fri, 3 Jul 2026 23:09:16 +0000 (16:09 -0700)] 
Rework size-overrun check to avoid arithmetic errors

3 weeks ago[Write] Truncate write-to-fd at the declared entry size
Tim Kientzle [Fri, 3 Jul 2026 20:05:41 +0000 (13:05 -0700)] 
[Write] Truncate write-to-fd at the declared entry size

This is the fix for....

Update the common archive_read_data_into_fd() to truncate
output to the actual entry size from the most recent
archive_read_header result.

This addresses a hole in handling of certain subtly-malformed archives
that can have more data than declared in the header.  Before this,
bsdtar explicitly truncates the entry data to the actual declared size
when extracting to a file, but did not do so when extracting to
stdout.

3 weeks ago[Write] Truncate write-to-fd at the declared entry size
Tim Kientzle [Fri, 3 Jul 2026 19:57:07 +0000 (12:57 -0700)] 
[Write] Truncate write-to-fd at the declared entry size

This is the test for....

Update the common archive_read_data_into_fd() to truncate
output to the actual entry size from the most recent
archive_read_header result.

This addresses a hole in handling of certain subtly-malformed archives
that can have more data than declared in the header.  Before this,
bsdtar explicitly truncates the entry data to the actual declared size
when extracting to a file, but did not do so when extracting to
stdout.

3 weeks ago[Zip] Reject archives if the 32-bit size field is not correct 3240/head
Tim Kientzle [Sat, 4 Jul 2026 04:25:54 +0000 (21:25 -0700)] 
[Zip] Reject archives if the 32-bit size field is not correct

Reverse an old experiment: When the 32-bit size field is provided, it
now must match the actual size exactly.  We no longer permit it to
only match the least-significant 32 bits of the actual size.

--begin-history--
When developing the earliest versions of libarchive's Zip support, I
experimented with the idea of supporting greater-than-4GiB entries in
32-bit Zip archives.  This proved to be technically feasible as long
as the _compressed_ data was small enough to keep the resulting
archive under 4GiB.  But this also required us to interpret
the 32-bit uncompressed size field as representing only the
least-significant 32 bits of the size.
--end-history--