Skip to content

Enforce dimension limits in TiffDecoder and AvifDecoder set_limits - #3133

Open
tanjiroK-coder wants to merge 1 commit into
image-rs:mainfrom
tanjiroK-coder:decoder-set-limits-dimensions
Open

tanjiroK-coder wants to merge 1 commit into
image-rs:mainfrom
tanjiroK-coder:decoder-set-limits-dimensions

Conversation

@tanjiroK-coder

Copy link
Copy Markdown

TiffDecoder::set_limits reads the image dimensions from self.info, but that field is only populated once prepare_image has run. In the order the ImageDecoder protocol documents, and the order ImageReaderOptions::into_decoder uses, set_limits runs first, so it checked a placeholder of 0x0 and strict max_image_width/max_image_height limits were silently accepted for any TIFF; ImageReader::decode is unaffected because it re-checks the layout, but a decoder handed to DynamicImage::from_decoder decodes at full size. This is a regression from the decoder refactor in e6a182c, which replaced the previous self.dimensions() call with the dummy and adjusted the test to call prepare_image before set_limits. AvifDecoder::set_limits has the same gap in a simpler form: it stores the limits without calling check_support or check_dimensions. Both now look up the real layout the way the trait default and the other decoders do. The prepare_image workaround in tests/limits.rs is removed, so the existing tiff and avif assertions fail on main and pass with this change (the avif test only runs with avif-native, which I built locally via the internal dav1d build).

This branch has not been deployed

No deployments
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