source2rosetta/fuzz/fuzz_targets/fuzz_schema.rs
Kamal Tufekcic c458b4cb50
All checks were successful
CI / lint (push) Successful in 17s
CI / fuzz (push) Successful in 1m52s
CI / test (push) Successful in 24s
read what the binary says about itself: names, signatures, prototypes; gen v2
2026-07-29 20:09:21 +03:00

33 lines
1.3 KiB
Rust

#![no_main]
//! The Source-2 SchemaSystem reader walks reloc-slot candidates as `SchemaClassInfoData_t` structs,
//! chasing `m_pFields`/`m_pBaseClasses` pointers. A crafted (or truncated) `.so` can point those
//! anywhere; the reader must survive it with `Err`/empty, never a panic. Also exercises the field and
//! base-class accessors the derivation reads.
use source2rosetta::elf::CodeImage;
use source2rosetta::schema;
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
let Ok(img) = CodeImage::from_bytes(data.to_vec()) else {
return;
};
// The enum bindings are a SECOND table read the same reloc-driven way: a name pointer, a
// width/count word, and an enumerator array whose length that word supplies. A crafted count is the
// sharp edge — it drives the per-enumerator read loop — so the reader must bound it rather than
// trust it.
for e in schema::enumerate_enums(&img) {
let _ = (e.name.len(), e.size, e.align);
for (n, v) in &e.values {
let _ = (n.len(), *v);
}
}
for c in schema::enumerate_schema(&img) {
let _ = c.primary_base();
for f in &c.fields {
let _ = (f.offset, f.name.len());
}
for b in &c.bases {
let _ = (b.offset, b.name.len());
}
}
});