File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,9 @@ name = "fuzz_log"
34
34
path = " fuzz_targets/fuzz_log.rs"
35
35
test = false
36
36
doc = false
37
+
38
+ [[bin ]]
39
+ name = " fuzz_packed_buffer"
40
+ path = " fuzz_targets/fuzz_packed_buffer.rs"
41
+ test = false
42
+ doc = false
Original file line number Diff line number Diff line change
1
+ #![ no_main]
2
+
3
+ use anyhow:: Result ;
4
+ use arbitrary:: Arbitrary ;
5
+ use bstr:: BStr ;
6
+ use gix_ref:: { packed:: Buffer , FullNameRef } ;
7
+ use libfuzzer_sys:: fuzz_target;
8
+ use std:: hint:: black_box;
9
+
10
+ #[ derive( Debug , Arbitrary ) ]
11
+ struct Ctx < ' a > {
12
+ packed_file_contents : & ' a [ u8 ] ,
13
+ name : & ' a [ u8 ] ,
14
+ }
15
+
16
+ fn fuzz ( ctx : Ctx ) -> Result < ( ) > {
17
+ let buffer = Buffer :: from_bytes ( ctx. packed_file_contents ) ?;
18
+ _ = black_box ( buffer. iter ( ) ?. count ( ) ) ;
19
+
20
+ let full_name_ref: & FullNameRef = BStr :: new ( ctx. name ) . try_into ( ) ?;
21
+ let name = full_name_ref. as_partial_name ( ) ;
22
+
23
+ _ = black_box ( buffer. try_find ( name) ) ;
24
+ _ = black_box ( buffer. find ( name) ) ;
25
+
26
+ Ok ( ( ) )
27
+ }
28
+
29
+ fuzz_target ! ( |ctx: Ctx | {
30
+ _ = black_box( fuzz( ctx) ) ;
31
+ } ) ;
You can’t perform that action at this time.
0 commit comments