File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -6,30 +6,44 @@ libFuzzer relies on LLVM sanitizer support. The Rust compiler has built-in suppo
6
6
7
7
# How to use
8
8
9
- “Manual” usage of this library looks like this:
9
+ Use [ cargo-fuzz] .
10
+
11
+ [ cargo-fuzz ] : https://github.com/rust-fuzz/cargo-fuzz
12
+
13
+ This crate can also be used manually as following:
14
+
15
+ First create a new cargo project:
10
16
11
17
```
12
18
$ cargo new --bin fuzzed
13
19
$ cd fuzzed
20
+ ```
21
+
22
+ Then add a dependency on the fuzzer-sys crate and your own crate:
14
23
15
- $ tail Cargo. toml -n2 # add libfuzzer-sys dependency
24
+ ``` toml
16
25
[dependencies ]
17
- fuzzer-sys = { path = "../libfuzzer-sys" } # or something
26
+ fuzzer-sys = { path = " ../libfuzzer-sys" } # or something, will eventually publish to crates.io
27
+ your_crate = " *" # or something
28
+ ```
18
29
19
- $ cat src/main.rs
30
+ and change the ` src/main.rs ` to fuzz your code:
31
+
32
+ ``` rust
20
33
#![no_main]
21
34
22
35
#[macro_use]
23
36
extern crate fuzzer_sys;
37
+ extern crate your_crate;
24
38
25
39
fuzz_target! (| data | {
26
40
// code to fuzz goes here
27
41
});
42
+ ```
28
43
44
+ Finally, run the following commands:
45
+
46
+ ```
29
47
$ cargo rustc -- -C passes='sancov' -C llvm-args='-sanitizer-coverage-level=3' -Z sanitizer=address -Cpanic=abort
30
48
$ ./target/debug/fuzzed # runs fuzzing
31
49
```
32
-
33
- For a nice wrapper see [ cargo-fuzz] .
34
-
35
- [ cargo-fuzz ] : https://github.com/rust-fuzz/cargo-fuzz
You can’t perform that action at this time.
0 commit comments