diff --git a/Cargo.toml b/Cargo.toml index 7cd89254..9bc030bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ include = [ [dependencies] bitflags = "1.0" crc32fast = "1.2.0" -fdeflate = "0.2.0" +fdeflate = "0.2.1" flate2 = "1.0" miniz_oxide = "0.6.0" diff --git a/src/decoder/zlib.rs b/src/decoder/zlib.rs index 9ade2ad2..5b00f546 100644 --- a/src/decoder/zlib.rs +++ b/src/decoder/zlib.rs @@ -40,9 +40,12 @@ impl Compressor { (TINFLStatus::HasMoreOutput, in_consumed, out_consumed) } Err(fdeflate::DecompressionError::NotFDeflate) => { - *self = Compressor::FullZlib(DecompressorOxide::new()); - + // fdeflate guarantees that it will detect non-fdeflate streams before + // consuming any input. If that happens, sanity check that no output + // has been produced and feed the same input to a full zlib decoder. assert_eq!(output_position, 0); + + *self = Compressor::FullZlib(DecompressorOxide::new()); self.decompress(input, output, output_position, end_of_input) } Err(_) => (TINFLStatus::Failed, 0, 0),