From f85b5cb7b873144692c4f84d6f8d89b3c097bfc6 Mon Sep 17 00:00:00 2001 From: Peter Williams <peter@newton.cx> Date: Sat, 12 Aug 2017 14:30:37 -0400 Subject: [PATCH] Add a test for ZIP64 with leading junk. I constructed this file using a hack from the Zip manpage: if the input to a Zip compression command is streamed on standard input, the output is given in ZIP64 format since the tool doesn't know how big the input will be. I modified the resulting file by adding some leading junk text and editing the non-ZIP64 end-of-central-directory structure to have 0xFFFF for its "number of files" parameters, to help the test demonstrate that the ZIP64 data are being properly read. (0xFFFF is the value used in the non-ZIP64 structure if the archive actually has more than 65535 files.) --- src/read.rs | 11 +++++++++++ tests/data/zip64_demo.zip | Bin 0 -> 224 bytes 2 files changed, 11 insertions(+) create mode 100644 tests/data/zip64_demo.zip diff --git a/src/read.rs b/src/read.rs index f8ac295f..cb3f0725 100644 --- a/src/read.rs +++ b/src/read.rs @@ -465,4 +465,15 @@ mod test { let reader = ZipArchive::new(io::Cursor::new(v)); assert!(reader.is_err()); } + + #[test] + fn zip64_with_leading_junk() { + use std::io; + use super::ZipArchive; + + let mut v = Vec::new(); + v.extend_from_slice(include_bytes!("../tests/data/zip64_demo.zip")); + let reader = ZipArchive::new(io::Cursor::new(v)).unwrap(); + assert!(reader.len() == 1); + } } diff --git a/tests/data/zip64_demo.zip b/tests/data/zip64_demo.zip new file mode 100644 index 0000000000000000000000000000000000000000..f2ceee303ee32da77509bd153a914aaeae0ce1ad GIT binary patch literal 224 zcmeZCO-#wmOIOG$&CAx~3h-uT(PaRERfRm>63auY|3d*Ig9w8zBZB|~A6S|JPJ5*0 z<mBrpl;;=aq$mOnU}TbGMl}MY1B4l&Ize=UAc&(I;LXOS0~Lm8196d+g82F%0tg%- c6a!EnJBV2T<%84*c(byBxF83E)I-z)074id761SM literal 0 HcmV?d00001