rust-lang / flate2-rs

DEFLATE, gzip, and zlib bindings for Rust
https://docs.rs/flate2
Apache License 2.0
929 stars 163 forks source link

Decoding a zip file returns the Error "corrupt deflate stream" #397

Closed santiwanti closed 9 months ago

santiwanti commented 9 months ago

I have a zip file which can be decoded with the macos archive utiliity and with windows 7zip, but can't be decoded with flate2. According to 7zip the file is a compressed using Deflate fast.

I'm using version 1.0.28 of the library and have tried the Deflate, Gz, and Zlib decoders.

Are there some zip formats that this library can't decode? Is it possible that the programs that can decode the file silently ignore some errors and just push through and manage to decode the file properly?

jongiddy commented 9 months ago

The compression algorithm used by flate2 is DEFLATE. gzip and Zlib are containers for DEFLATE-compressed data. The flate2 crate encodes and decodes DEFLATE-compressed files to/from gzip or zlib containers or not in any container.

zip is a different container format. It supports multiple compression algorithms including DEFLATE. flate2 does not support the zip container format. I suggest that you look for a zip-specific crate.

santiwanti commented 9 months ago

thanks @jongiddy I had no idea they were different. the naming of deflate being part of zip confused me