Fix accidental infinite loop in fuzz targets (#5103)

The `libfuzzer-sys` update in #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.
This commit is contained in:
Alex Crichton
2022-10-24 09:14:42 -05:00
committed by GitHub
parent 470070ab71
commit 37c3342374
2 changed files with 4 additions and 4 deletions

View File

@@ -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);

View File

@@ -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()?;