Conversation
Funny thing about iff: if not all tiles are present in a corrupt file, there is no read error per se, but not all of m_buf staging area gets overwritten, leading to reveal of stale heap data (since m_heap is a default_init_vector). Fixed by zero-filling the buffer. We timed and this is a negligible cost, since the pre-fill with zero ends up bringing the whole thing in cache, making the actual decode into the buffer cheaper than if it was touching the memory for the first time. Add several new tests for full coverage of all code paths that might involve this kind of situation. Assisted-by: Claude Code / claude-opus-5 Signed-off-by: Larry Gritz <lg@larrygritz.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Full-buffer clearing can cause excessive memory use or termination when decoding sparse corrupt files.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes IFF decoding to prevent stale heap data from appearing in uncovered tile regions.
Changes:
- Zero-fills the staging buffer before tile decoding.
- Adds regression coverage for incomplete and unusual tile layouts.
- Updates expected test hashes and metadata.
File summaries
| File | Summary |
|---|---|
testsuite/iff/run.py |
Adds regression test commands. |
testsuite/iff/ref/out.txt |
Updates expected metadata and hashes. |
src/iff.imageio/iffinput.cpp |
Clears the staging buffer before decoding. |
Review details
- Files reviewed: 3/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Funny thing about iff: if not all tiles are present in a corrupt file, there is no read error per se, but not all of m_buf staging area gets overwritten, leading to reveal of stale heap data (since m_heap is a default_init_vector). Fixed by zero-filling the buffer. We timed and this is a negligible cost, since the pre-fill with zero ends up bringing the whole thing in cache, making the actual decode into the buffer cheaper than if it was touching the memory for the first time.
Add several new tests for full coverage of all code paths that might involve this kind of situation.
Assisted-by: Claude Code / claude-opus-5