Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seemingly incorrect Avif bit depth assertion #2145

Closed
soupslurpr opened this issue Feb 12, 2024 · 2 comments · Fixed by #2146
Closed

Seemingly incorrect Avif bit depth assertion #2145

soupslurpr opened this issue Feb 12, 2024 · 2 comments · Fixed by #2146

Comments

@soupslurpr
Copy link
Contributor

I'm using Windows 11, Rust 1.76.0 latest stable and MSVC.

When trying to parse an Avif file that has a bit depth other than 8, this assertion is triggered.

C:\Users\user.cargo\registry\src\index.crates.io-6f17d22bba15001f\image-0.24.8\src\codecs\avif\decoder.rs:59:9:
assertion left == right failed
left: 10
right: 8

I used these images to test

8 bit depth: https://raw.githubusercontent.com/link-u/avif-sample-images/master/fox.profile1.8bpc.yuv444.avif
10 bit depth: https://raw.githubusercontent.com/link-u/avif-sample-images/master/fox.profile1.10bpc.yuv444.avif

It seems Avif supports 8, 10, and 12 bit depths.
https://aomediacodec.github.io/av1-avif/v1.1.0.html#biblio-av1:~:text=NOTE%3A%20%5BAV1%5D%20supports%203%20bit%20depths%3A%208%2C%2010%20and%2012%20bits

Also, I don't think there should be an assertion at all as I think a denial of service can happen by a malicious Avif file (that sets the bit depth to an unsupported amount)?

Expected

File decodes normally

Actual behaviour

panics from assertion

Reproduction steps

let bytes = // open the Avif image in bytes
image::load_from_memory(bytes).unwrap();

@fintelia
Copy link
Contributor

Yeah, at the moment we don't support 10 or 12 bit AVIF images. Agreed that this should be an "Unsupported" error rather than an assert until support is added though

@soupslurpr
Copy link
Contributor Author

I made a pull request to do that #2146 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants