Skip to content

Commit

Permalink
Fix accidental infinite loop in fuzz targets
Browse files Browse the repository at this point in the history
The `libfuzzer-sys` update in bytecodealliance#5068 included some changes to the
`fuzz_target!` macro which caused a bare `run` function to be shadowed
by the macro-defined `run` function (changed in
rust-fuzz/libfuzzer#95) which meant that some of our fuzz targets were
infinite looping or stack overflowing as the same function was called
indefinitely. This renames the top-level `run` function to something
else in the meantime.
  • Loading branch information
alexcrichton committed Oct 24, 2022
1 parent ecbf223 commit 5772a4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/differential.rs
Expand Up @@ -53,10 +53,10 @@ fuzz_target!(|data: &[u8]| {

// Errors in `run` have to do with not enough input in `data`, which we
// ignore here since it doesn't affect how we'd like to fuzz.
drop(run(&data));
drop(execute_one(&data));
});

fn run(data: &[u8]) -> Result<()> {
fn execute_one(data: &[u8]) -> Result<()> {
STATS.bump_attempts();

let mut u = Unstructured::new(data);
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/instantiate-many.rs
Expand Up @@ -12,10 +12,10 @@ const MAX_MODULES: usize = 5;
fuzz_target!(|data: &[u8]| {
// errors in `run` have to do with not enough input in `data`, which we
// ignore here since it doesn't affect how we'd like to fuzz.
drop(run(data));
drop(execute_one(data));
});

fn run(data: &[u8]) -> Result<()> {
fn execute_one(data: &[u8]) -> Result<()> {
let mut u = Unstructured::new(data);
let mut config: generators::Config = u.arbitrary()?;

Expand Down

0 comments on commit 5772a4e

Please sign in to comment.