mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 18:52:47 +08:00
test: add bounded fuzz targets and native-WASM parity
This commit is contained in:
1 parent
e0dc177885
commit
767eae2a79
14 files changed
+1111
-3
No files matched your search
@@ -0,0 +1,19 @@
|
||||
#![no_main]
|
||||
|
||||
//! Static PE integrity check over arbitrary images.
|
||||
//!
|
||||
//! The checker is documented never to panic on any input; this target enforces
|
||||
//! that. Input is capped so a crafted `SizeOfImage` cannot turn one iteration
|
||||
//! into a multi-gigabyte allocation.
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
const MAX_INPUT: usize = 512 * 1024;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let data = &data[..data.len().min(MAX_INPUT)];
|
||||
let report = senbei_engine::check_integrity(data);
|
||||
// Keep the report observable so the optimizer cannot elide the call.
|
||||
std::hint::black_box(report.issues.len());
|
||||
std::hint::black_box(report.findings.len());
|
||||
});
|
||||
Reference in new issue
Block a user