File tree Expand file tree Collapse file tree 6 files changed +46
-9
lines changed Expand file tree Collapse file tree 6 files changed +46
-9
lines changed Original file line number Diff line number Diff line change @@ -12,5 +12,8 @@ notifications:
12
12
email : false
13
13
script :
14
14
- cd example
15
- - cargo rustc -- -C passes='sancov' -C llvm-args='-sanitizer-coverage-level=3' -Z sanitizer=address
16
- - (! ./target/debug/example)
15
+ - cargo rustc --release -- -C passes='sancov' -C llvm-args='-sanitizer-coverage-level=4' -Z sanitizer=address
16
+ - (! ./target/release/example -runs=100000)
17
+ - cd ../example_arbitrary
18
+ - cargo rustc --release -- -C passes='sancov' -C llvm-args='-sanitizer-coverage-level=4' -Z sanitizer=address
19
+ - (! ./target/release/example -runs=10000000)
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ license = "MIT/Apache-2.0/NCSA"
12
12
members = [" ." ]
13
13
14
14
[dependencies ]
15
+ arbitrary = " 0.1"
15
16
16
17
[build-dependencies ]
17
18
gcc = " 0.3"
Original file line number Diff line number Diff line change 3
3
#[ macro_use]
4
4
extern crate libfuzzer_sys;
5
5
6
- fuzz_target ! ( |data| {
7
- if data == b"banana" {
6
+ fuzz_target ! ( |data: & [ u8 ] | {
7
+ if data == b"banana! " {
8
8
panic!( "success!" ) ;
9
9
}
10
10
} ) ;
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " example"
3
+ version = " 0.1.0"
4
+ authors = [
" Simonas Kazlauskas <[email protected] >" ]
5
+
6
+ [workspace ]
7
+ members = [" ." ]
8
+
9
+ [dependencies ]
10
+ libfuzzer-sys = { path = " .." }
11
+ arbitrary = " 0.1"
Original file line number Diff line number Diff line change
1
+ #![ no_main]
2
+
3
+ #[ macro_use]
4
+ extern crate libfuzzer_sys;
5
+
6
+ fuzz_target ! ( |data: u16 | {
7
+ if data == 0xba7 { // ba[nana]
8
+ panic!( "success!" ) ;
9
+ }
10
+ } ) ;
Original file line number Diff line number Diff line change 1
- #![ feature( process_abort) ]
2
-
3
1
extern "C" {
4
2
#![ allow( improper_ctypes) ] // we do not actually cross the FFI bound here
5
3
@@ -23,10 +21,24 @@ macro_rules! fuzz_target {
23
21
$body
24
22
}
25
23
} ;
26
- ( |$bytes: ident: & [ u8 ] | $body: block) => {
24
+ ( |$data: ident: & [ u8 ] | $body: block) => {
25
+ fuzz_target!( |$data| $body) ;
26
+ } ;
27
+ ( |$data: ident: $dty: ty| $body: block) => {
28
+ extern crate arbitrary;
29
+
27
30
#[ no_mangle]
28
- pub extern fn rust_fuzzer_test_input( $bytes: & [ u8 ] ) {
31
+ pub extern fn rust_fuzzer_test_input( bytes: & [ u8 ] ) {
32
+ use arbitrary:: { Arbitrary , RingBuffer } ;
33
+
34
+ let $data: $dty = if let Ok ( d) = RingBuffer :: new( bytes, bytes. len( ) ) . and_then( |mut b|{
35
+ Arbitrary :: arbitrary( & mut b) . map_err( |_| "" )
36
+ } ) {
37
+ d
38
+ } else {
39
+ return
40
+ } ;
29
41
$body
30
42
}
31
- }
43
+ } ;
32
44
}
You can’t perform that action at this time.
0 commit comments