fix(lzx,amiga_lzx): reject ≥4 GiB input instead of truncating the u32 length header - #117
Closed
MagicalTux wants to merge 1 commit into
Closed
fix(lzx,amiga_lzx): reject ≥4 GiB input instead of truncating the u32 length header#117MagicalTux wants to merge 1 commit into
MagicalTux wants to merge 1 commit into
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 #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:
self.raw.len() as u32At ≥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