remram44/adler32-rs

overflow panic in update_buffer

Closed this issue · 1 comments

Original issue from oyvindln
Monday September 19, 2016 11:53 UTC
See rs-sync#6


Calling RollingAdler32::update_buffer() on a long slice causes a panic due to overflow:

thread 'tests::it_works' panicked at 'attempted to add with overflow', /<removed>/registry/src/github.com-1ecc6299db9ec823/adler32-0.2.0/src/lib.rs:55

Code that reproduces the issue:

        let mut c = RollingAdler32::new();
        let buffer = vec![255; 64000];
        c.update_buffer(&buffer);

I presume the fix would be to use wrapping_add to indicate that overflows are supposed to happen.

Monday September 19, 2016 15:35 UTC
Comment from remram44


Thanks for the report, this is fixed with 718dea1d. I also added a test case for this and published 0.3 to crates.io.