Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Use BufReader read encrypt zip has error: corrupt deflate stream #280

Closed
zjzdy opened this issue Mar 5, 2022 · 2 comments
Closed

Use BufReader read encrypt zip has error: corrupt deflate stream #280

zjzdy opened this issue Mar 5, 2022 · 2 comments
Labels

Comments

@zjzdy
Copy link

zjzdy commented Mar 5, 2022

When I use zip::ZipArchive::new(BufReader::new(File::open(zip_path).unwrap())) to open file, decompress happen error: Custom { kind: InvalidInput, error: "corrupt deflate stream" }. But zip::ZipArchive::new(File::open(zip_path).unwrap()) is ok.
Version: zip = "0.5.13" (The git version also has the problem.)
toolchain: stable-x86_64-pc-windows-msvc
rustc 1.58.1 (db9d1b20b 2022-01-20)
The file compress by 7z.
Password: 52gv
Code and Data: testzip.zip
Only zip file: data.zip

Code:

use std::fs::File;
use std::io::{BufReader, Read};

fn main() {
    let zip_path = "data.zip";
    let result = zip::ZipArchive::new(BufReader::new(File::open(zip_path).unwrap()));
    if let Ok(mut archive) = result {
        for index in 0..archive.len() {
            let result = archive.by_index_decrypt(index, "52gv".as_ref());
            if let Ok(Result::Ok(mut zipfile)) = result {
                println!("{}:{}", zipfile.name(), zipfile.size());
                let mut buff = [0u8; 1024*8];
                loop {
                    let size = zipfile.read(&mut buff).unwrap();
                    if size == 0 {
                        break;
                    }
                }
            }
        }
    }
}
@zamazan4ik zamazan4ik added the bug label Mar 8, 2022
@zamazan4ik
Copy link
Contributor

@Plecra Do you know anything about the bug? Maybe we had something similar before.

@Plecra
Copy link
Member

Plecra commented Mar 8, 2022

Doesn't look familiar. It'll be a problem with how we're feeding the decrypted data through

biluohc added a commit to biluohc/zipcs that referenced this issue May 21, 2022
awaken1ng added a commit to awaken1ng/zip-rs that referenced this issue Feb 16, 2024
Fixes `corrupt deflate stream` panic when extracting a file from encrypted archive (zip-rs#280).
awaken1ng added a commit to awaken1ng/zip-rs that referenced this issue Apr 27, 2024
Fixes `corrupt deflate stream` panic when extracting a file from encrypted archive (zip-rs#280).
awaken1ng added a commit to awaken1ng/zip-rs that referenced this issue Apr 27, 2024
Fixes `corrupt deflate stream` panic when extracting a file from encrypted archive (zip-rs#280).
awaken1ng added a commit to awaken1ng/zip-rs that referenced this issue Apr 27, 2024
Fixes `corrupt deflate stream` panic when extracting a file from encrypted archive (zip-rs#280).
awaken1ng added a commit to awaken1ng/zip-rs that referenced this issue Apr 27, 2024
Fixes `corrupt deflate stream` panic when extracting a file from encrypted archive (zip-rs#280).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants