Bug fix: remove size check since metadata may be wrong

This commit is contained in:
Chris Hennick 2024-02-29 12:33:40 -08:00
parent e843e67b9f
commit 3f3d78c9ee

View file

@ -9,12 +9,9 @@ fn decompress_all(data: &[u8]) -> Result<(), Box<dyn std::error::Error>> {
let mut zip = zip_next::ZipArchive::new(reader)?; let mut zip = zip_next::ZipArchive::new(reader)?;
for i in 0..zip.len() { for i in 0..zip.len() {
let file = zip.by_index(i)?;
let expected_bytes = file.size().min(MAX_BYTES_TO_READ); let expected_bytes = file.size().min(MAX_BYTES_TO_READ);
let result = std::io::copy(&mut file.take(MAX_BYTES_TO_READ), &mut std::io::sink()); let file = zip.by_index(i)?.take(MAX_BYTES_TO_READ);
if let Ok(bytes) = result { std::io::copy(&mut file, &mut std::io::sink())?;
assert!(bytes <= expected_bytes)
}
} }
Ok(()) Ok(())