image-rs / jpeg-decoder

JPEG decoder written in Rust -- currently in maintenance mode
Apache License 2.0
148 stars 89 forks source link

'attempt to add with overflow' #63

Closed Nemo157 closed 7 years ago

Nemo157 commented 7 years ago

I'm using this library to detect valid jpeg images for generating an afl-rs logo, basically fuzzing whether an input stream decodes or not. While doing this I came across one image that passed the fuzzer in release mode, but then panicked when I tried loading in debug mode, testing with the provided decode example gives the same result:

$ cargo run --release --example decode -- crash.jpg
    Finished release [optimized] target(s) in 0.0 secs
     Running `target/release/examples/decode crash.jpg`

$ cargo run --example decode -- crash.jpg
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/examples/decode crash.jpg`
thread 'main' panicked at 'attempt to add with overflow', src/decoder.rs:551
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Process didn't exit successfully: `target/debug/examples/decode crash.jpg` (exit code: 101)

This file does load (albeit with different output) in Preview and Safari.

crash.jpg

kaksmet commented 7 years ago

Thanks for reporting this, I'm working on a fix.