Files
uc2/lib
Eremey Valetov 54f8e2a2b2 decompress: fix zero-length-match DoS (while(--len) underflow)
A crafted ~146-byte archive made the ULTRA decoder spin ~18s. The cause
was an integer underflow, not a compression-ratio bomb: a zero-length
match code reached the match-copy loop in decompress_block, where
while(--len) underflows len from 0 to ~4.29 billion and copies that many
bytes. A corrupt or unassigned Huffman length entry, or a truncated
extra-bits read, can yield len == 0.

Reject len == 0 alongside the existing len > cbuf_space guard, and check
the distance/length extra-bit reads for a negative (truncation) return
before they feed the unsigned length or distance. The fix covers the
cdir, master, and file-extract decodes since they share decompress_block.

Lock it in with a portable replay driver (fuzz_replay.c, needs no
Clang/ASan) and a fuzz_regression ctest that runs the committed artifact
plus the seed corpus under a 30s timeout on every platform in the matrix;
pre-fix that artifact hangs, post-fix it returns in milliseconds.

Closes b8f933c.
2026-06-14 05:27:40 -04:00
..