-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Describe the bug
When using the zip crate version 4.3.0 (and other 4.x versions), extracting a zip file containing a single large entry (over 4GB, deflated, with zip64 headers) will cause a panic in zlib-rs with an "attempt to add with overflow" error.
However, using the older zip = "0.6" version, the same file can be extracted successfully.
This issue does not occur with external tools like 7-Zip or WinRAR, and the zip file is valid and not corrupted.
Code-Example
use std::fs::File;
use zip::ZipArchive;
fn main() {
let file = File::open("Sample.zip").unwrap();
let mut archive = ZipArchive::new(file).unwrap();
for i in 0..archive.len() {
let mut file = archive.by_index(i).unwrap();
println!(
"entry {}: name={:?}, size={}, compressed_size={}, compression={:?}",
i,
file.name(),
file.size(),
file.compressed_size(),
file.compression()
);
let outpath = std::path::Path::new("output").join(file.name());
if let Some(parent) = outpath.parent() {
std::fs::create_dir_all(parent).unwrap();
}
let mut outfile = File::create(&outpath).unwrap();
std::io::copy(&mut file, &mut outfile).unwrap();
}
}
Tested with:
zip = "4.3.0" (fails with panic on large entry)
zip = "0.6" (works fine)
Sample output (with 4.3.0):
Apply to rzip_functio...
The same file can be extracted successfully with zip 0.6 and with 7-Zip/WinRAR.
Additional Notes
The problematic entry is a single file over 4GB, compressed with Deflate, with valid zip64 headers.
This is a regression from 0.6.x to 4.x.
This issue is critical for users needing to extract large files (e.g., Unity assets) in Rust.
Please fix zip64/large file support in 4.x, or document that 0.6.x is required for such use cases.