Add tests from fuzzing
Add test from fuzzing samples in #28, #29 and #31
This commit is contained in:
1 parent
bd0d66c09f
commit
95b153cdeb
77 files changed
+42
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,42 @@
|
|||||||
|
extern crate tiff;
|
||||||
|
|
||||||
|
use tiff::{TiffResult, ColorType};
|
||||||
|
use tiff::decoder::{Decoder, DecodingResult, ifd::Tag, ifd::Value};
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
|
||||||
|
fn test_directory<F: Fn(File) -> bool>(path: &str, f: F) {
|
||||||
|
for entry in std::fs::read_dir(path).unwrap() {
|
||||||
|
let file = File::open(entry.unwrap().path()).unwrap();
|
||||||
|
assert!(f(file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_tiff(file: File) -> TiffResult<()> {
|
||||||
|
let mut decoder = Decoder::new(file)?;
|
||||||
|
decoder.read_image()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn oor_panic() {
|
||||||
|
test_directory("./tests/fuzz_images/oor_panic", |file| {
|
||||||
|
decode_tiff(file).ok();
|
||||||
|
true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn oom_crash() {
|
||||||
|
test_directory("./tests/fuzz_images/oom_crash", |file| {
|
||||||
|
decode_tiff(file).is_err()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inf_loop() {
|
||||||
|
test_directory("./tests/fuzz_images/inf_loop", |file| {
|
||||||
|
decode_tiff(file).ok();
|
||||||
|
true
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in new issue
Block a user