-
Notifications
You must be signed in to change notification settings - Fork 618
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
Memory Allocation Failed in image::DynamicImage::resize_exact
#2340
Comments
I no longer investigate fuzzing reports against parts of the API surface that haven't been hardened against untrusted input. But if you want to submit a PR, feel free! |
This doesn't need to be obfuscated as base64. Investigated on the playground, it's a farbfeld image with a 0 dimension. use image;
use image::GenericImageView;
fn main() {
// use base64; // 0.22.1
// use base64::prelude::*;
// let s = BASE64_STANDARD.decode("ZmFyYmZlbGT/UMnJAAAAAAAAAAAAANj/Nw8A").unwrap();
// farbfeld\xffP\xc9\xc9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd8\xff7\x0f\x00
let s = [
102u8, 97, 114, 98, 102, 101, 108, 100, 255, 80, 201, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
216, 255, 55, 15, 0,
];
let im = image::load_from_memory(&s).unwrap();
dbg!(im.dimensions());
// [src/main.rs:15:5] im.dimensions() = (
// 4283484617,
// 0,
// )
} It aborts when you try to
Guessing it's here around L473 where the width is multiplied by the height. Lines 466 to 474 in a373218
But it might've failed before this if original image had a 1px height. Not sure if |
The image buffer in the base64 ends up having size: |
While performing fuzz testing on the
image::DynamicImage::resize_exact
function, I discovered an input that can cause a program crash.Expected
The program should catch this crash-inducing condition and return an error instead of crashing.
Actual behaviour
Crash with memory allocation failed.
Reproduction steps
When run, the following output is produced:
version:
The text was updated successfully, but these errors were encountered: