source2rosetta/fuzz/fuzz_targets/fuzz_xref.rs
Kamal Tufekcic 22ab973f0c
All checks were successful
CI / lint (push) Successful in 16s
CI / fuzz (push) Successful in 2m3s
CI / test (push) Successful in 25s
minor tweaks
2026-08-03 03:59:53 +03:00

21 lines
895 B
Rust

#![no_main]
//! The whole-binary cross-reference index decodes every function's `[start,next)` range and records
//! call/data references; the string-anchor locators then query it. Feeding arbitrary code + rodata
//! bytes exercises the decode, the containing-function lookup, and the string search — none may panic.
use source2rosetta::elf::CodeImage;
use source2rosetta::xref;
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
let Ok(img) = CodeImage::from_bytes(data.to_vec()) else {
return;
};
let xr = xref::XrefIndex::build(&img);
// Exercise the lookups over a bounded set of the discovered function entries — none may panic.
for &t in xr.entries().iter().take(64) {
let _ = xr.referrers(t);
let _ = xr.refs_to(t);
let _ = xr.containing_func(t);
}
let _ = xref::funcs_using_string(&img, &xr, "CBaseEntity");
});