fix(lzx,amiga_lzx): reject ≥4 GiB input instead of truncating the u32 length header - #118
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 u32in the standalone header), missed by the stress campaign because they were never round-trip-tested at scale: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