| 1 |
extern crate tiffrust-analyzer cargo tiff 0.11.3 tiff/; |
| 2 |
|
| 3 |
use tiffrust-analyzer cargo tiff 0.11.3 crate/::decoderrust-analyzer cargo tiff 0.11.3 decoder/::Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#; |
| 4 |
use tiffrust-analyzer cargo tiff 0.11.3 crate/::TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#; |
| 5 |
|
| 6 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#; |
| 7 |
|
| 8 |
fn test_directoryrust-analyzer cargo tiff 0.11.3 test_directory().<F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#) -> bool>(path: &str, f: F) { |
| 9 |
for entry in stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_dir().(path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() { |
| 10 |
let file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(entry.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[DirEntry]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 11 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(f(file)); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
fn decode_tiffrust-analyzer cargo tiff 0.11.3 decode_tiff().(file: Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<()> { |
| 16 |
let mut decoder = Decoderrust-analyzer cargo tiff 0.11.3 decoder/Decoder#::newrust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]new().(file)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 17 |
decoder.read_imagerust-analyzer cargo tiff 0.11.3 decoder/impl#[`Decoder<R>`]read_image().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 18 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 19 |
} |
| •20 |
/* |
| 21 |
#[test] |
| 22 |
fn oor_panic() { |
| 23 |
test_directory("./tests/fuzz_images/oor_panic", |file| { |
| 24 |
let _ = decode_tiff(file); |
| 25 |
true |
| 26 |
}); |
| 27 |
} |
| 28 |
|
| 29 |
#[test] |
| 30 |
fn oom_crash() { |
| 31 |
test_directory("./tests/fuzz_images/oom_crash", |file| { |
| 32 |
decode_tiff(file).is_err() |
| 33 |
}); |
| 34 |
} |
| 35 |
|
| 36 |
#[test] |
| 37 |
fn inf_loop() { |
| 38 |
test_directory("./tests/fuzz_images/inf_loop", |file| { |
| 39 |
let _ = decode_tiff(file); |
| 40 |
true |
| 41 |
}); |
| 42 |
} |
| 43 |
|
| 44 |
// https://github.com/image-rs/image-tiff/issues/33 |
| 45 |
#[test] |
| 46 |
fn divide_by_zero() { |
| 47 |
test_directory("./tests/fuzz_images/divide_by_zero", |file| { |
| 48 |
let _ = decode_tiff(file); |
| 49 |
true |
| 50 |
}); |
| 51 |
} |
| •52 |
*/ |