Skip to content

Regression in decompressing bad data using miniz_oxide>=0.8.5 w/ small input #499

@milesgranger

Description

@milesgranger

Copying the issue from miniz_oxide: Frommi/miniz_oxide#174

xref: milesgranger/cramjam#211

Seems a decompression error only arrives if the bad input data is over 4 characters long:

This does not raise an error:

    fn decompress_bad_data() {
        let mut decoder = DeflateDecoder::new(b"1".as_slice());
        let mut out = vec![];
        assert!(std::io::copy(&mut decoder, &mut out).is_err());
    }

But this will, 5 bytes at least for me, seems to spark the error, up to 4 bytes will not raise an error.

    fn decompress_bad_data() {
        let mut decoder = DeflateDecoder::new(b"12345".as_slice());
        let mut out = vec![];
        assert!(std::io::copy(&mut decoder, &mut out).is_err());
    }

And as pointed out in the linked issue, it actually depends on what the first byte is on whether it fails as expected or not - further adding to the awkwardness.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions