Skip to content

Commit a8e1e57

Browse files
committed
WIP
1 parent 79d1b68 commit a8e1e57

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

Cargo.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/fuzzers/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
authors = ["The Fe Developers <[email protected]>"]
3+
edition = "2021"
4+
name = "fe-fuzzers"
5+
version = "0.26.0"
6+
license = "GPL-3.0-or-later"
7+
repository = "https://github.com/ethereum/fe"
8+
9+
[dependencies]
10+
fe-common = {path = "../common", version = "^0.26.0"}
11+
fe-driver = {path = "../driver", version = "^0.26.0"}
12+
libfuzzer-sys = "0.4"
13+
14+
dir-test = "^0.1"
15+
16+
[lib]
17+
name = "single_file_fuzzer"
18+
path = "src/single_file_fuzzer.rs"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
use fe_common::diagnostics::print_diagnostics;
5+
6+
fuzz_target!(|data: &[u8]| {
7+
// Convert the fuzzing engine input to a string
8+
let input = String::from_utf8_lossy(data);
9+
10+
// Create a mutable database
11+
let mut db = fe_driver::Db::default();
12+
13+
// Call the `compile_single_file` API with the input
14+
let _ = match fe_driver::compile_single_file(
15+
&mut db,
16+
"dummy",
17+
&input,
18+
/*with_bytecode=*/ true,
19+
/*with_runtime_bytecode=*/ true,
20+
/*optimize=*/ true,
21+
) {
22+
Ok(_) => (),
23+
Err(error) => {
24+
eprintln!("Unable to compile input.");
25+
print_diagnostics(&db, &error.0);
26+
}
27+
};
28+
});

0 commit comments

Comments
 (0)