From 2dae0d4a5cfa335cb01b382a006a3ed610cf6de6 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Wed, 5 Jul 2017 21:36:47 +0200 Subject: [PATCH] Add regression test for #40 --- src/read.rs | 14 ++++++++++++++ tests/data/invalid_offset.zip | Bin 0 -> 1241 bytes 2 files changed, 14 insertions(+) create mode 100644 tests/data/invalid_offset.zip diff --git a/src/read.rs b/src/read.rs index 01dc0fa5..752dce1d 100644 --- a/src/read.rs +++ b/src/read.rs @@ -386,3 +386,17 @@ impl<'a> Read for ZipFile<'a> { self.get_reader().read(buf) } } + +#[cfg(test)] +mod test { + #[test] + fn invalid_offset() { + use std::io; + use super::ZipArchive; + + let mut v = Vec::new(); + v.extend_from_slice(include_bytes!("../tests/data/invalid_offset.zip")); + let reader = ZipArchive::new(io::Cursor::new(v)); + assert!(reader.is_err()); + } +} diff --git a/tests/data/invalid_offset.zip b/tests/data/invalid_offset.zip new file mode 100644 index 0000000000000000000000000000000000000000..9ff2e07fa8d61d9c3595645ae5c78d83220c8830 GIT binary patch literal 1241 zcmWIWW@h1H0D+eUx4gg%D8a%Y!%&r3pdT8-$-w;eM?j>~&w$9%3T_5QmamKq3@jo* zbpb%#AesZL``hCW%dP==ED{V1yinbGF2V7^CHY0EaAQD5p&9dbh9TD>2LadrM-&)m z>*{{zx|hIN#iXyGaie3R$C}_uz5cXAb%7?05t_f`dDfpeqn24#Cf4xuY8smbgXE$@ zH+9L!tu5Om&Ps{)El=HfU-WnG_bB}>Ta(uWE;#aVuIMy zyo)uifBVl`^}Js32!Ha+8q4z+>mOeG7Iptfm*w>6#Pf~{o#Ji5cRt(5zOagFXH>L1 zD2fQ2nDkp-Vwc-;=K=%gI}r0h1IIbBC_P`VBtJI?96BFf1VrXwhE8k0A>UyI9@p~u zOdHv)!e4m?uyOb~_;MT)Sh=$5`>chltU~Ag+dhAP?xwl#$_@%nx*Kq(#U@#9l`ePK zq=JNnJC?tT7n$C2=Z=)-2IJdP1rAi4nPIa`Q>piW#rJthom+z!Uh@fG8`<{k%9i{p z>l&v^w#z4o=tnG`eY-MA@`YplgG(#;YNP%Kbh-c1GB|eBq;9`vhOK;V_79Dt3qP=d zJPAoZRT-%1ha2k2lbVIahjpb$Cj zbD)|X=qPU>HfBI}WGkwHmT4)8DaIz2DT&FZ<`!la=80xTmImf2DdtIuCPtQ~76yiC ziKb>|p&^7Vo&mIYozbUXe}R@x2ZjYVip4*n78j)^rsx$FgAMe@^4 z1_ofz>_77R|Nqu$t@_2OsVSg{209RHS%HYYx4^O{i=iWT6VQR6(n1(+9w_?iSs+0T eF%LCe{Kd>40p6@^Ky!eF5C_9npx^3PK|BDRjB7^# literal 0 HcmV?d00001