Describe the bug
When writing a zip file, if I used .large_file(true) the file is written with an incorrect CRC. This causes 7-Zip and Windows Explorer at least to fail to extract the zip. CRC errors are also shown by unzip -t from the command line.
The problem does not occur with .large_file(false).
To Reproduce
Steps to reproduce the behaviour:
Build and run this code to create test.zip:
use std::{fs::File, io::Write};
use zip::write::{SimpleFileOptions, ZipWriter};
fn main() {
let file = File::create("test.zip").unwrap();
let mut zip = ZipWriter::new(file);
let options = SimpleFileOptions::default()
.compression_method(zip::CompressionMethod::Stored)
.large_file(true);
zip.start_file("hello_world.txt", options).unwrap();
zip.write(b"Hello\nWorld!").unwrap();
zip.finish().unwrap();
}
2. Run `unzip -t test.zip` from the command line. It will show these errors:
$ unzip -t test.zip
Archive: test.zip
testing: hello_world.txt bad CRC d7daaffa (should be 77e47a71)
At least one error was detected in test.zip.
3. Try to extract test.zip using 7-Zip. It will show these errors:
1 C:\Work\experiments\rust\zip_test\test.zip
Unexpected end of data
2 CRC failed : hello_world.txt
4. Try to "Extract All.." the file within Windows Explorer. It will fail with error `0x80004005: Unspecified error` on `hello_world.txt`.
Note that this all works without errors if `.large_file(true)` is removed. The file reads correctly using the `zip` crate itself, which might indicate problems with the reader as well.
**Expected behavior**
The zip file should not produce errors with `unzip -t` and should open and extract correctly with other programs. Maybe tests should be added to check files with `unzip -t` to avoid this type of error in the future.
**Screenshots**
The Window Explorer error:
![image](https://github.com/zip-rs/zip2/assets/30094120/4f332533-24bd-43d2-a04a-af8a54a77af4)
**Desktop (please complete the following information):**
- OS: Windows 10
- Crate version: 2.1.3
Describe the bug When writing a zip file, if I used
.large_file(true)
the file is written with an incorrect CRC. This causes 7-Zip and Windows Explorer at least to fail to extract the zip. CRC errors are also shown byunzip -t
from the command line.The problem does not occur with
.large_file(false)
.To Reproduce Steps to reproduce the behaviour:
test.zip
:fn main() { let file = File::create("test.zip").unwrap(); let mut zip = ZipWriter::new(file); let options = SimpleFileOptions::default() .compression_method(zip::CompressionMethod::Stored) .large_file(true); zip.start_file("hello_world.txt", options).unwrap(); zip.write(b"Hello\nWorld!").unwrap(); zip.finish().unwrap(); }
$ unzip -t test.zip Archive: test.zip testing: hello_world.txt bad CRC d7daaffa (should be 77e47a71) At least one error was detected in test.zip.
1 C:\Work\experiments\rust\zip_test\test.zip Unexpected end of data 2 CRC failed : hello_world.txt