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

Panic in gif::Decoder::into_frames on invalid background color #816

Closed
moulins opened this issue Sep 28, 2018 · 4 comments
Closed

Panic in gif::Decoder::into_frames on invalid background color #816

moulins opened this issue Sep 28, 2018 · 4 comments

Comments

@moulins
Copy link

moulins commented Sep 28, 2018

This small program, along with this image: invalid-bg-color.gif - invalid-bg-color

extern crate image;

use image::ImageDecoder;

fn main() {
   
    let file = std::fs::File::open("invalid-bg-color.gif").unwrap();
    let decoder = image::gif::Decoder::new(std::io::BufReader::new(file));
    let _frames = decoder.into_frames().unwrap();
}

Produces the following crash:

   8: core::slice::slice_index_len_fail
             at libcore/slice/mod.rs:1971
   9: <core::ops::range::Range<usize> as core::slice::SliceIndex<[T]>>::index
             at /checkout/src/libcore/slice/mod.rs:2136
  10: core::slice::<impl core::ops::index::Index<I> for [T]>::index
             at /checkout/src/libcore/slice/mod.rs:1953
  11: <image::gif::Decoder<R> as image::image::ImageDecoder>::into_frames
             at /home/XXX/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.20.0/./src/gif.rs:139
  12: gif_test::main
             at src/main.rs:10

But opening the image with image::load("invalid-bg-color.gif") works correctly.


The input image is a copy of this image, but with the background color set to the invalid value 0xFF, which causes an out-of-bound access in the Global Color Table.

Some GIFs in the wild use such an invalid value when the background color is never used, so these files should be parsed correctly (even if this technically is an invalid GIF).

@fintelia
Copy link
Contributor

fintelia commented Oct 7, 2018

Is this now fixed?

@moulins
Copy link
Author

moulins commented Oct 7, 2018

This is fixed on image-gif v0.10.1, but image still uses v0.10.0, so we'll have to wait a little more ;)

@Shnatsel
Copy link
Contributor

Shnatsel commented Mar 2, 2019

This testcase no longer causes a crash. I believe this bug is fixed and can be closed.

@bvssvni
Copy link
Contributor

bvssvni commented Mar 2, 2019

Closing.

@bvssvni bvssvni closed this as completed Mar 2, 2019
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

No branches or pull requests

4 participants