mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-25 02: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,24 @@
|
||||
#![no_main]
|
||||
|
||||
//! Metadata restorers that depend on a decoded module.
|
||||
//!
|
||||
//! The first byte splits the input into a seed selector and the metadata
|
||||
//! bytes, so both `restore_method_tokens` and the v24.1 method-index restore
|
||||
//! get structured-but-arbitrary inputs. Bounded to 2 MiB per iteration.
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
const MAX_INPUT: usize = 2 * 1024 * 1024;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let data = &data[..data.len().min(MAX_INPUT)];
|
||||
let Some((&selector, body)) = data.split_first() else {
|
||||
return;
|
||||
};
|
||||
let seed = u32::from(selector);
|
||||
let _ = senbei_metadata::android::restore_method_tokens(body, seed);
|
||||
// The module bytes are attacker-shaped too: an arbitrary "module 0x0C"
|
||||
// must fail validation, never panic.
|
||||
let _ = senbei_metadata::android::restore_method_indices_v24_1(body, body);
|
||||
let _ = senbei_metadata::android::extract_embedded_metadata(body);
|
||||
});
|
||||
Reference in new issue
Block a user