rust-fuzz / cargo-fuzz

Command line helpers for fuzzing
https://rust-fuzz.github.io/book/cargo-fuzz.html
Apache License 2.0
1.55k stars 110 forks source link

Add an option to disable instrumenting Rust code for fuzzing #340

Open Voker57 opened 1 year ago

Voker57 commented 1 year ago

The reason for this is sometimes I only want to fuzz the specific part of code, and don't want to fuzz the whole Rust crate stack.

fitzgen commented 1 year ago

I only want to fuzz the specific part of code, and don't want to fuzz the whole Rust crate

This PR would turn off fuzzing instrumentation for all code though, including the "specific part of code" so I don't think this is doing what you say you want to do?

Unfortunately, I don't think there is a good way to do what you describe other than writing your fuzz target such that code you don't want to fuzz is statically unreachabel (i.e. your fuzz target can only exercise the code you want to fuzz).

Voker57 commented 1 year ago

I only want to fuzz the specific part of code, and don't want to fuzz the whole Rust crate

This PR would turn off fuzzing instrumentation for all code though, including the "specific part of code" so I don't think this is doing what you say you want to do?

Unfortunately, I don't think there is a good way to do what you describe other than writing your fuzz target such that code you don't want to fuzz is statically unreachabel (i.e. your fuzz target can only exercise the code you want to fuzz).

The code I'm talking about is already instrumented and linked as a static library. Alternatively, I could manually enable fuzzing for a specific crate, though this might have a better solution.