File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ target
2
+ corpus
3
+ artifacts
4
+ coverage
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " sliceslice-fuzz"
3
+ version = " 0.0.0"
4
+ publish = false
5
+ edition = " 2021"
6
+
7
+ [package .metadata ]
8
+ cargo-fuzz = true
9
+
10
+ [dependencies ]
11
+ arbitrary = { version = " 1.3.0" , features = [" derive" ] }
12
+ libfuzzer-sys = " 0.4"
13
+ sliceslice = { version = " 0.4.1" , path = " .." }
14
+
15
+ # Prevent this from interfering with workspaces
16
+ [workspace ]
17
+ members = [" ." ]
18
+
19
+ [profile .release ]
20
+ debug = 1
21
+
22
+ [[bin ]]
23
+ name = " dynamic_avx2"
24
+ path = " fuzz_targets/dynamic_avx2.rs"
25
+ test = false
26
+ doc = false
Original file line number Diff line number Diff line change
1
+ #![ no_main]
2
+
3
+ use arbitrary:: Arbitrary ;
4
+ use libfuzzer_sys:: fuzz_target;
5
+ use sliceslice:: x86:: DynamicAvx2Searcher ;
6
+
7
+ #[ derive( Arbitrary , Debug ) ]
8
+ struct FuzzInput < ' a > {
9
+ needle : & ' a [ u8 ] ,
10
+ haystack : & ' a [ u8 ] ,
11
+ position : usize ,
12
+ }
13
+
14
+ fuzz_target ! ( |input: FuzzInput <' _>| {
15
+ let mut input = input;
16
+
17
+ // This is a documented panic, so avoid it
18
+ if !input. needle. is_empty( ) {
19
+ input. position %= input. needle. len( ) ;
20
+ }
21
+
22
+ let result = unsafe {
23
+ let searcher = DynamicAvx2Searcher :: with_position( input. needle, input. position) ;
24
+ searcher. search_in( input. haystack)
25
+ } ;
26
+
27
+ let expected = match input. needle. len( ) {
28
+ 0 => true ,
29
+ len => input. haystack. windows( len) . any( |w| w == input. needle) ,
30
+ } ;
31
+
32
+ assert_eq!( result, expected) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments