Skip to content

fix(lzx,amiga_lzx): reject ≥4 GiB input instead of truncating the u32 length header - #118

Merged
MagicalTux merged 1 commit into
masterfrom
fix/lzx-amiga-lzx-4gib
Jul 8, 2026
Merged

fix(lzx,amiga_lzx): reject ≥4 GiB input instead of truncating the u32 length header#118
MagicalTux merged 1 commit into
masterfrom
fix/lzx-amiga-lzx-4gib

Conversation

@MagicalTux

Copy link
Copy Markdown
Member

Follow-on to the large-file robustness work (#116). A static audit found two more codecs with the 32-bit total-length-header truncation bug (self.raw.len() as u32 in the standalone header), missed by the stress campaign because they were never round-trip-tested at scale:

  • lzx — 5-byte header stores uncompressed size as u32
  • amiga_lzx — identical u32 total-length header

At ≥4 GiB the header truncated → decoder emitted the wrong byte count (corruption). Fix: reject over-length input with a clean Error::Unsupported, matching snappy/lzss.

Verified: round-trip below 4 GiB, clean fast error at ≥4 GiB. Other newly-audited codecs are clean — crunch/squashed (arc LZW) round-trip at 4.5 GiB, squeeze/lha self-terminate (no length header), quantum/lzah/rar*/sit13/lzham/ppmd/arsenic are decode-only.

Full suite 1708 green; fmt + clippy clean. (Supersedes #117, which auto-closed when its branch was deleted during a concurrent release merge.)

🤖 Generated with Claude Code

…ngth

Both write the total uncompressed size as a little-endian u32 in the
standalone header (`self.raw.len() as u32`), so at >= 4 GiB the length
silently truncated and the decoder emitted the wrong byte count — the
same 32-bit-length-header class fixed for snappy/lzss in #116. A static
audit of the remaining round-trippable codecs (several wrongly assumed
decode-only) found these two; the earlier stress run never reached them.
Reject over-length input with a clean `Error::Unsupported`.

Verified: both round-trip below 4 GiB and error cleanly at >= 4 GiB. The
other newly-checked codecs are fine — crunch/squashed (arc LZW)
round-trip at 4.5 GiB, squeeze/lha self-terminate (no length header), and
quantum/lzah/rar*/sit13/lzham/ppmd/arsenic are decode-only. Full suite
1708 green; fmt + clippy clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@MagicalTux
MagicalTux merged commit 04a6db2 into master Jul 8, 2026
43 checks passed
@MagicalTux
MagicalTux deleted the fix/lzx-amiga-lzx-4gib branch July 8, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant