]> git.ipfire.org Git - thirdparty/libarchive.git/log
thirdparty/libarchive.git
2 weeks agoMerge pull request #3286 from uchiha-bug-hunter/xar-parse-time-overread
Tim Kientzle [Mon, 13 Jul 2026 14:36:17 +0000 (07:36 -0700)] 
Merge pull request #3286 from uchiha-bug-hunter/xar-parse-time-overread

xar: fix one-byte over-read in parse_time date parser

2 weeks agoxar: fix one-byte over-read in parse_time date parser 3286/head
Kaif Khan [Mon, 13 Jul 2026 14:01:09 +0000 (19:31 +0530)] 
xar: fix one-byte over-read in parse_time date parser

2 weeks agowarc: clarify resource header size error 3284/head
datauwu [Mon, 13 Jul 2026 08:52:33 +0000 (16:52 +0800)] 
warc: clarify resource header size error

Use a more specific error when resource header generation fails.

The old message said `cannot archive file`, but this path fails when
the generated WARC resource header exceeds the internal limit.

2 weeks agowarc: propagate generated header errors
datauwu [Mon, 13 Jul 2026 08:52:31 +0000 (16:52 +0800)] 
warc: propagate generated header errors

Check generated WARC header creation and writes.

Fail when the generated warcinfo header cannot be built. Treat a
resource header build failure as fatal because output may already exist.

Propagate write errors instead of marking the record as written.

2 weeks agowarc: test generated header write errors
datauwu [Mon, 13 Jul 2026 08:52:25 +0000 (16:52 +0800)] 
warc: test generated header write errors

Add memory-writer tests for generated WARC header write failures.

Cover both the warcinfo header and a resource header with warcinfo
disabled. These tests show that header write failures are hidden.

2 weeks agopax: add "align" write option for reflink-friendly archives 3272/head
Daan De Meyer [Thu, 9 Jul 2026 11:34:40 +0000 (13:34 +0200)] 
pax: add "align" write option for reflink-friendly archives

Add a per-format "align" option to the pax writer that pads each
regular file's pax extended header (creating one if necessary) so the
file data that follows begins on a multiple of the requested number of
bytes within the uncompressed archive stream.  The value must be a
power of two and a multiple of the 512-byte tar block.

The alignment is applied to the stream feeding into any compression
filter, so the decompressed archive is aligned regardless of whether
the archive is compressed.  This lets tools share file contents out of
an (uncompressed copy of an) archive using reflinks / copy_file_range(2)
instead of doing a full data copy on extraction.

The padding is carried in an ignorable "LIBARCHIVE.pad" pax record, so
existing readers extract the archive unchanged.  Files shorter than the
alignment are left unpadded since they cannot share a whole block.

Add a test covering uncompressed and gzip-compressed archives and
document the option.

Signed-off-by: Daan De Meyer <daan@amutable.com>
2 weeks agocpio: add regression test for symlink-trailer end-of-archive check 3278/head
Kaif Khan [Mon, 13 Jul 2026 06:14:09 +0000 (11:44 +0530)] 
cpio: add regression test for symlink-trailer end-of-archive check

A symlink entry named TRAILER!!! with a body large enough to grow the
read filter's copy buffer used to leave the cached name pointer stale
before the end-of-archive comparison.  Read a static newc archive in
small blocks and assert the trailer is still detected (ARCHIVE_EOF).

The fix landed in 23b54da; this only adds coverage.

2 weeks agoMerge pull request #3270 from daandemeyer/push-qnzponoyonzo
Dustin L. Howett [Mon, 13 Jul 2026 04:05:02 +0000 (23:05 -0500)] 
Merge pull request #3270 from daandemeyer/push-qnzponoyonzo

test_sparse_basic: avoid out-of-bounds pointer arithmetic in verify

2 weeks agoMerge pull request #3282 from datauwu/warc-reject-incomplete-resource-records
Dustin L. Howett [Mon, 13 Jul 2026 03:51:31 +0000 (22:51 -0500)] 
Merge pull request #3282 from datauwu/warc-reject-incomplete-resource-records

warc: reject incomplete resource records

2 weeks agoMerge pull request #3285 from datauwu/uu-fix-null-memcpy-ub
Dustin L. Howett [Mon, 13 Jul 2026 03:20:46 +0000 (22:20 -0500)] 
Merge pull request #3285 from datauwu/uu-fix-null-memcpy-ub

uu: fix null pointer UB in EOF buffering

2 weeks agouu: fix null pointer UB in EOF buffering 3285/head
datauwu [Sun, 12 Jul 2026 14:04:12 +0000 (22:04 +0800)] 
uu: fix null pointer UB in EOF buffering

The uu filter can keep a partial encoded line in its internal input
buffer, then reach upstream EOF with no new bytes available. In that
case, d is NULL and avail_in is zero, but the buffered-input path still
passes d to memcpy() before processing the saved bytes.

Skip the append copy when avail_in is zero so the saved input is handled
without passing a null source pointer to memcpy().

2 weeks agoMerge pull request #3277 from datauwu/cpio-fix-pointer-lifetime
Dustin L. Howett [Sat, 11 Jul 2026 12:23:18 +0000 (07:23 -0500)] 
Merge pull request #3277 from datauwu/cpio-fix-pointer-lifetime

2 weeks agoMerge pull request #3280 from stoeckmann/warc_cleanup
Dustin L. Howett [Sat, 11 Jul 2026 12:17:58 +0000 (07:17 -0500)] 
Merge pull request #3280 from stoeckmann/warc_cleanup

2 weeks agowarc: reject incomplete resource records 3282/head
datauwu [Sat, 11 Jul 2026 12:16:39 +0000 (20:16 +0800)] 
warc: reject incomplete resource records

Reject resource records when less data was written than Content-Length.

Do not append the WARC end marker after a short entry. Return fatal
because the record body has already been started.

This avoids writing a record whose length does not match its body.

2 weeks agowarc: test incomplete resource records
datauwu [Sat, 11 Jul 2026 12:16:24 +0000 (20:16 +0800)] 
warc: test incomplete resource records

Add a writer test for a resource entry shorter than Content-Length.

The test closes after a short write and checks for a fatal error. It
documents that the end marker must not hide a short body.

2 weeks agoMerge pull request #3281 from stoeckmann/warc_bid_check
Dustin L. Howett [Sat, 11 Jul 2026 12:14:05 +0000 (07:14 -0500)] 
Merge pull request #3281 from stoeckmann/warc_bid_check

2 weeks agowarc: Sort include headers 3280/head
Tobias Stoeckmann [Sat, 11 Jul 2026 08:54:44 +0000 (10:54 +0200)] 
warc: Sort include headers

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agowarc: Unify private function names
Tobias Stoeckmann [Sat, 11 Jul 2026 08:53:03 +0000 (10:53 +0200)] 
warc: Unify private function names

Use same style as in other format parsers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agowarc: Use common function names
Tobias Stoeckmann [Sat, 11 Jul 2026 08:48:11 +0000 (10:48 +0200)] 
warc: Use common function names

Apply same style used in other format parsers.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agowarc: Use proper data type for unconsumed
Tobias Stoeckmann [Sat, 11 Jul 2026 08:42:13 +0000 (10:42 +0200)] 
warc: Use proper data type for unconsumed

Match other parsers and use int64_t to avoid casts and switching between
signed and unsigned.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agowarc: Simplify __archive_read_ahead check 3281/head
Tobias Stoeckmann [Sat, 11 Jul 2026 11:19:25 +0000 (13:19 +0200)] 
warc: Simplify __archive_read_ahead check

A short read would lead to a NULL return value, thus the second check
will never be true.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoMerge pull request #3279 from datauwu/warc-modernize-comments
Tobias Stoeckmann [Sat, 11 Jul 2026 10:01:19 +0000 (12:01 +0200)] 
Merge pull request #3279 from datauwu/warc-modernize-comments

warc: modernize comments

2 weeks agowarc: modernize writer comments 3279/head
datauwu [Sat, 11 Jul 2026 08:47:24 +0000 (16:47 +0800)] 
warc: modernize writer comments

Rewrite WARC writer comments to use clearer wording and consistent
terminology.

Keep the change comment-only while preserving existing behavior.

2 weeks agowarc: modernize reader comments
datauwu [Sat, 11 Jul 2026 08:47:23 +0000 (16:47 +0800)] 
warc: modernize reader comments

Rewrite WARC reader comments to use clearer wording and match the
style used by other libarchive format readers.

Keep the change comment-only while preserving existing behavior.

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 #3276 from DHowett/dh/fix-archive-literals
Tim Kientzle [Sat, 11 Jul 2026 03:40:54 +0000 (20:40 -0700)] 
Merge pull request #3276 from DHowett/dh/fix-archive-literals

tidy: prefer ARCHIVE_OK over 0 when appropriate

2 weeks agowrite: prefer ARCHIVE_OK over literal in set_bytes_per_block 3276/head
Dustin L. Howett [Sat, 11 Jul 2026 01:16:55 +0000 (20:16 -0500)] 
write: prefer ARCHIVE_OK over literal in set_bytes_per_block

2 weeks agoiso9660: prefer ARCHIVE_OK over literal in gen*identifier
Dustin L. Howett [Fri, 10 Jul 2026 23:43:16 +0000 (18:43 -0500)] 
iso9660: prefer ARCHIVE_OK over literal in gen*identifier

2 weeks agoshar: prefer ARCHIVE_OK over literal in finish_entry
Dustin L. Howett [Fri, 10 Jul 2026 23:42:31 +0000 (18:42 -0500)] 
shar: prefer ARCHIVE_OK over literal in finish_entry

2 weeks agoxz: prefer ARCHIVE_OK over literal in filter_open
Dustin L. Howett [Fri, 10 Jul 2026 23:41:08 +0000 (18:41 -0500)] 
xz: prefer ARCHIVE_OK over literal in filter_open

2 weeks agouuencode: prefer ARCHIVE_OK over literal in filter_open
Dustin L. Howett [Fri, 10 Jul 2026 23:40:56 +0000 (18:40 -0500)] 
uuencode: prefer ARCHIVE_OK over literal in filter_open

2 weeks agocompress: prefer ARCHIVE_OK over literal in filter_open
Dustin L. Howett [Fri, 10 Jul 2026 23:40:44 +0000 (18:40 -0500)] 
compress: prefer ARCHIVE_OK over literal in filter_open

2 weeks agob64: prefer ARCHIVE_OK over literal in filter_open
Dustin L. Howett [Fri, 10 Jul 2026 23:40:29 +0000 (18:40 -0500)] 
b64: prefer ARCHIVE_OK over literal in filter_open

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 agotest_sparse_basic: avoid out-of-bounds pointer arithmetic in verify 3270/head
Daan De Meyer [Thu, 9 Jul 2026 12:51:05 +0000 (14:51 +0200)] 
test_sparse_basic: avoid out-of-bounds pointer arithmetic in verify

When a sparse map entry began before the current data block
(expected_offset < offset), verify_sparse_file() formed the intermediate
pointer "buff + (expected_offset - offset)" before adding the entry
size.  That intermediate points before buff, which is undefined behavior;
with file4's large hole it trapped the test under UBSan
(-fsanitize=pointer-overflow).  Fold the size into the displacement so the
whole byte offset is computed as one integer and added to buff in a
single, in-bounds step.

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.

2 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.

2 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.

2 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 agooptions: Use const char pointer where possible 3264/head
Tobias Stoeckmann [Tue, 7 Jul 2026 15:12:58 +0000 (17:12 +0200)] 
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>
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 agocab: Use strnlen if possible 3247/head
Tobias Stoeckmann [Sun, 5 Jul 2026 19:36:30 +0000 (21:36 +0200)] 
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>
3 weeks agomtree: Fix custom strnlen API
Tobias Stoeckmann [Sun, 5 Jul 2026 19:35:14 +0000 (21:35 +0200)] 
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>
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