ende76 / brotli-rs

A Brotli implementation in pure and safe Rust
Apache License 2.0
63 stars 19 forks source link

Panic when decompressing #3

Closed frewsxcv closed 9 years ago

frewsxcv commented 9 years ago
extern crate brotli;

use std::io::Read;
use brotli::Decompressor;

fn main() {
    let mut input = vec![];
    let _ = Decompressor::new(&b"\xb1".to_vec() as &[u8]).read_to_end(&mut input);
}
coreyf@frewbook-pro /t/meow (master)> cargo run
     Running `target/debug/meow`
thread '<main>' panicked at '"Encountered unexpected EOF"', /Users/coreyf/.cargo/git/checkouts/brotli-rs-33811c30552ad7ba/master/src/lib.rs:2280
Process didn't exit successfully: `target/debug/meow` (exit code: 101)

Panic discovered using afl.rs

ende76 commented 9 years ago

Ah yes, thanks again. This was more my inexperience with Rust conventions than anything else. Now, instead of panicking outright, read() properly passes through the possible error conditions.