Skip to content

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

Closed
MagicalTux wants to merge 1 commit into
masterfrom
fix/lzx-amiga-lzx-4gib
Closed

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

Conversation

@MagicalTux

Copy link
Copy Markdown
Member

Follow-on to #116. A static audit for the two large-file bug patterns found in that PR (u32 length headers, fixed sanity guards) — reaching codecs the stress harness never round-trip-tested — turned up two more with the 32-bit total-length-header truncation:

  • lzx — 5-byte standalone header stores the uncompressed size as self.raw.len() as u32
  • amiga_lzx — identical u32 total-length header

At ≥4 GiB the header silently truncated → the decoder emitted the wrong number of bytes (corruption). Both were missed by the earlier campaign because they were never round-trip-tested at scale (I'd wrongly assumed some codecs were decode-only). Fix: reject over-length input with a clean Error::Unsupported, matching snappy/lzss.

Verified: both round-trip below 4 GiB and error cleanly (fast) at ≥4 GiB. Everything else newly checked is clean — 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 (encode returns Unsupported).

Full suite 1708 green; fmt + clippy clean.

🤖 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]>
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