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:
1212 email : false
1313script :
1414 - 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"
1212members = [" ." ]
1313
1414[dependencies ]
15+ arbitrary = " 0.1"
1516
1617[build-dependencies ]
1718gcc = " 0.3"
Original file line number Diff line number Diff line change 33#[ macro_use]
44extern crate libfuzzer_sys;
55
6- fuzz_target ! ( |data| {
7- if data == b"banana" {
6+ fuzz_target ! ( |data: & [ u8 ] | {
7+ if data == b"banana! " {
88 panic!( "success!" ) ;
99 }
1010} ) ;
Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " example"
3+ version = " 0.1.0"
4+ authors = [" Simonas Kazlauskas <git@kazlauskas.me>" ]
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-
31extern "C" {
42 #![ allow( improper_ctypes) ] // we do not actually cross the FFI bound here
53
@@ -23,10 +21,24 @@ macro_rules! fuzz_target {
2321 $body
2422 }
2523 } ;
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+
2730 #[ 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+ } ;
2941 $body
3042 }
31- }
43+ } ;
3244}
You can’t perform that action at this time.
0 commit comments