source2rosetta/fuzz/fuzz_targets/fuzz_rtti.rs
Kamal Tufekcic a2922b8bad
All checks were successful
CI / fuzz (push) Successful in 1m41s
CI / lint (push) Successful in 16s
CI / test (push) Successful in 22s
initial commit
2026-07-27 10:12:04 +03:00

21 lines
918 B
Rust

#![no_main]
//! The Itanium RTTI reader chases `_ZTV`/`_ZTI`/`_ZTS` pointer chains and demangles names out of the
//! bytes; `enumerate_vtables` sweeps every reloc slot as a candidate typeinfo. Arbitrary bytes must
//! not panic it (or the demangler). Also runs the `NetworkStateChanged` slot detector over the slots.
use source2rosetta::elf::CodeImage;
use source2rosetta::rtti;
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
let Ok(img) = CodeImage::from_bytes(data.to_vec()) else {
return;
};
let vts = rtti::enumerate_vtables(&img, 128);
for cv in vts.iter().take(32) {
let _ = (&cv.name, &cv.mangled, cv.offset_to_top, cv.slots.len());
}
// The by-name lookup path (mangling + candidate walk) on a name pulled from the input itself.
if let Some(name) = vts.first().map(|c| c.name.clone()) {
let _ = rtti::find_vtable(&img, &name, 128);
}
});