Skip to content

Commit

Permalink
Refactor: use a zip file with valid metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0methean committed Mar 4, 2024
1 parent f4d5ad7 commit c1afa95
Showing 1 changed file with 5 additions and 40 deletions.
45 changes: 5 additions & 40 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,46 +1365,11 @@ mod test {
#[cfg(feature = "deflate64")]
#[test]
fn deflate64_index_out_of_bounds() -> std::io::Result<()> {
let file: [u8; 815] = [
80, 75, 1, 255, 5, 80, 75, 1, 2, 255, 255, 255, 153, 38, 0, 9, 0, 0, 0, 0, 0, 4, 6, 6,
80, 75, 5, 6, 0, 64, 6, 6, 75, 80, 0, 41, 0, 1, 0, 2, 80, 75, 5, 6, 0, 0, 0, 0, 1, 0,
0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 0, 0,
0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 191, 191, 191, 191, 6, 5,
4, 80, 75, 0, 0, 5, 0, 35, 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 5,
75, 80, 0, 1, 0, 1, 0, 9, 0, 9, 199, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 253, 255, 0, 0, 117, 117, 75, 4, 6, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 7, 5, 75, 80, 0, 1, 0, 1, 0, 9, 0, 9, 191, 191, 191,
191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 253, 255, 0, 0, 117, 117,
75, 5, 6, 0, 1, 0, 1, 0, 0, 0, 0, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 191, 253, 255, 0, 0, 117, 117, 75, 5, 6, 0, 1, 80, 75, 3, 4, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, 1, 1, 75, 80, 0, 0, 0, 0, 0, 0, 2, 80, 75, 0, 0,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 6, 5, 65, 2, 0, 0, 0, 0, 0,
0, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 255, 255, 255, 255, 255, 255, 69, 69, 69, 69, 69, 69, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 69, 69, 69, 69, 68, 69, 240, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 6, 5, 75, 80, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 62, 69, 69, 69, 69, 69, 69, 69, 1, 0, 0, 0, 0, 0, 0, 16, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 129,
129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 7, 5, 75, 80, 129,
129, 129, 129, 129, 48, 1, 0, 0, 0, 0, 0, 0, 129, 129, 129, 129, 129, 129, 129, 129,
129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 0,
0, 0, 0, 0, 69, 69, 69, 69, 69, 69, 61, 43, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 192, 192, 192, 192,
192, 192, 192, 192, 0, 35, 0, 0, 0, 0, 0, 0, 5, 6, 0, 0, 1, 0, 0, 0, 9, 4, 253, 255, 6,
5, 75, 80, 0, 0, 0, 2, 0, 132, 255, 255, 255, 107, 1, 0, 0, 0, 0, 69, 129, 129, 129,
129, 129, 129, 73, 129, 129, 129, 129, 129, 129, 129, 129, 7, 5, 75, 80, 129, 129, 129,
129, 129, 129, 129, 129, 129, 129, 129, 129, 74, 129, 129, 129, 129, 129, 129, 129,
129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 0, 0, 0, 0, 0, 69, 69, 69,
69, 69, 69, 61, 61, 1, 0, 0, 0, 0, 0, 0, 16, 61, 61, 61, 61, 255, 255, 255, 255, 255,
255, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 80, 191, 0,
];
let mut reader = ZipArchive::new(Cursor::new(file))?;
let mut v = Vec::new();
v.extend_from_slice(include_bytes!(

Check failure on line 1369 in src/read.rs

View workflow job for this annotation

GitHub Actions / clippy

couldn't read src/../tests/data/raw_deflate64_index_out_of_bounds.zip: No such file or directory (os error 2)

Check failure on line 1369 in src/read.rs

View workflow job for this annotation

GitHub Actions / Build and test (macOS-latest, nightly)

couldn't read src/../tests/data/raw_deflate64_index_out_of_bounds.zip: No such file or directory (os error 2)
"../tests/data/raw_deflate64_index_out_of_bounds.zip"
));
let mut reader = ZipArchive::new(Cursor::new(v))?;
std::io::copy(&mut reader.by_index(0)?, &mut std::io::sink()).expect_err("Invalid file");
Ok(())
}
Expand Down

0 comments on commit c1afa95

Please sign in to comment.