Skip to content

Commit

Permalink
clusterfuzz test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
royaltm committed May 1, 2024
1 parent 77dc54b commit 8d0179b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const TESTS_CASES: &[(&str, &[(&str, Option<&str>, u64, u64, u16, u32, &str, u8,
])
];

const CRASH_TESTS: &[&str] = &[
"clusterfuzz-1.bin"
];

#[test]
fn test_regression() -> io::Result<()> {
for (name, headers) in TESTS_CASES {
Expand Down Expand Up @@ -112,5 +116,16 @@ fn test_regression() -> io::Result<()> {
}
}
}

for name in CRASH_TESTS {
println!("-------------\n{:?}", name);
let file = fs::File::open(format!("tests/regression/{}", name))?;
let mut lha_reader = delharc::LhaDecodeReader::new(&file)?;
assert!(lha_reader.is_decoder_supported());
let mut sink = SinkSum::new();
let err = io::copy(&mut lha_reader, &mut sink).unwrap_err();
assert_eq!(&err.to_string(), "temporary codelen table has invalid size");
}
Ok(())
}

4 changes: 4 additions & 0 deletions tests/regression/README
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ comment.lzh - Archive created on Amiga with a file note embedded in
the file name.
Sent by @sonnenscheinchen
https://github.com/royaltm/rust-delharc/issues/1

clusterfuzz-1.bin - A generated file that caused panic in LhaV2Decoder.
Sent by @micahsnyder
https://github.com/royaltm/rust-delharc/issues/7
Binary file added tests/regression/clusterfuzz-1.bin
Binary file not shown.

0 comments on commit 8d0179b

Please sign in to comment.