Repository navigation
fix(image): AVIF dimensions and decode size are checked before the raster is decoded - #1516
Merged
Merged
Conversation
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.
Fixes #888
Root cause
crates/rune-image/src/avif.rs:rgbacalledavif_decode::Decoder::from_avif(bytes)?.to_image()and only then comparedw/hagainst 8192.crates/rune-image/src/lib.rsdecodesends AVIF toavif::rgbabefore it builds theimage::Limits(8192 px, 256 MiB) that other raster formats get.Change
avif::limits::checkruns beforeavif-decode. It reads headers only and allocates no pixels:iloccount and extent kept inside the input.ispeof the primary item and of its alpha (auxl+ alphaauxC) item.max_frame_width/height, bit depth, monochrome).frame_size_override_flag, because rav1d takes those sizes without comparing them to the sequence maximum.imagepath: at most 8192 px per side, and at most 256 MiB for the decoder's output buffer (16-bit RGBA counts 8 bytes per pixel).avif_tests.rsbuild small AVIF containers and OBUs in code. No test files are committed.