33
44use crate :: Tsffs ;
55use anyhow:: { anyhow, Result } ;
6- use getters :: Getters ;
6+ use getters2 :: Getters ;
77use libafl:: {
88 feedback_or, feedback_or_fast,
99 prelude:: {
@@ -41,7 +41,9 @@ pub mod tokenize;
4141
4242#[ derive( Getters , Clone , PartialEq , Eq ) ]
4343pub struct Testcase {
44+ #[ getters( clone) ]
4445 testcase : Vec < u8 > ,
46+ #[ getters( deref) ]
4547 cmplog : bool ,
4648}
4749
@@ -79,7 +81,7 @@ impl Tsffs {
7981
8082 /// Start the fuzzing thread.
8183 pub fn start_fuzzer_thread ( & mut self ) -> Result < ( ) > {
82- if self . fuzz_thread ( ) . is_some ( ) {
84+ if self . fuzz_thread_ref ( ) . is_some ( ) {
8385 warn ! ( self . as_conf_object( ) , "Fuzz thread already started but start_fuzzer_thread called. Returning without error." ) ;
8486 // We can only start the thread once
8587 return Ok ( ( ) ) ;
@@ -98,16 +100,16 @@ impl Tsffs {
98100 self . fuzzer_messages = Some ( mrx) ;
99101
100102 let client = RefCell :: new ( ( otx, orx) ) ;
101- let configuration = self . configuration ( ) . clone ( ) ;
103+ let configuration = self . configuration_clone ( ) ;
102104 let coverage_map = unsafe {
103105 from_raw_parts_mut (
104106 self . coverage_map_mut ( ) . as_mut_slice ( ) . as_mut_ptr ( ) ,
105107 Self :: COVERAGE_MAP_SIZE ,
106108 )
107109 } ;
108- let aflpp_cmp_map = Box :: leak ( unsafe { Box :: from_raw ( * self . aflpp_cmp_map_ptr ( ) ) } ) ;
109- let aflpp_cmp_map_dup = Box :: leak ( unsafe { Box :: from_raw ( * self . aflpp_cmp_map_ptr ( ) ) } ) ;
110- let cmplog_enabled = * self . configuration ( ) . cmplog ( ) ;
110+ let aflpp_cmp_map = Box :: leak ( unsafe { Box :: from_raw ( * self . aflpp_cmp_map_ptr_ref ( ) ) } ) ;
111+ let aflpp_cmp_map_dup = Box :: leak ( unsafe { Box :: from_raw ( * self . aflpp_cmp_map_ptr_ref ( ) ) } ) ;
112+ let cmplog_enabled = * self . configuration_ref ( ) . cmplog_ref ( ) ;
111113
112114 // NOTE: We do *not* use `run_in_thread` because it causes the fuzzer to block when HAPs arrive
113115 // which prevents forward progress.
@@ -174,12 +176,12 @@ impl Tsffs {
174176 let timeout_feedback = TimeFeedback :: new ( Self :: TIMEOUT_FEEDBACK_NAME ) ;
175177
176178 let solutions = OnDiskCorpus :: with_meta_format (
177- configuration. solutions_directory ( ) ,
179+ configuration. solutions_directory_ref ( ) ,
178180 OnDiskMetadataFormat :: JsonPretty ,
179181 ) ?;
180182
181183 let corpus = CachedOnDiskCorpus :: with_meta_format (
182- configuration. corpus_directory ( ) ,
184+ configuration. corpus_directory_ref ( ) ,
183185 Self :: CORPUS_CACHE_SIZE ,
184186 Some ( OnDiskMetadataFormat :: Json ) ,
185187 ) ?;
@@ -203,10 +205,10 @@ impl Tsffs {
203205
204206 let mut tokens = Tokens :: default ( ) ;
205207 configuration
206- . token_files ( )
208+ . token_files_ref ( )
207209 . iter ( )
208210 . try_for_each ( |f| tokens. add_from_file ( f) . map ( |_| ( ) ) ) ?;
209- tokens. add_tokens ( configuration. tokens ( ) ) ;
211+ tokens. add_tokens ( configuration. tokens_ref ( ) ) ;
210212 state. add_metadata ( tokens) ;
211213
212214 let scheduler =
@@ -270,29 +272,29 @@ impl Tsffs {
270272 ) ;
271273 let tracing_stage = TracingStage :: new ( tracing_executor) ;
272274 let synchronize_corpus_stage =
273- SyncFromDiskStage :: with_from_file ( configuration. corpus_directory ( ) . clone ( ) ) ;
275+ SyncFromDiskStage :: with_from_file ( configuration. corpus_directory_clone ( ) ) ;
274276 let dump_corpus_stage = DumpToDiskStage :: new (
275277 |input : & BytesInput , _state : & _ | input. target_bytes ( ) . as_slice ( ) . to_vec ( ) ,
276- configuration. corpus_directory ( ) ,
277- configuration. solutions_directory ( ) ,
278+ configuration. corpus_directory_ref ( ) ,
279+ configuration. solutions_directory_ref ( ) ,
278280 ) ?;
279281
280282 if state. must_load_initial_inputs ( ) {
281283 state. load_initial_inputs (
282284 & mut fuzzer,
283285 & mut executor,
284286 & mut manager,
285- & [ configuration. corpus_directory ( ) . clone ( ) ] ,
287+ & [ configuration. corpus_directory_ref ( ) . clone ( ) ] ,
286288 ) ?;
287289
288- if state. corpus ( ) . count ( ) < 1 && * configuration. generate_random_corpus ( ) {
290+ if state. corpus ( ) . count ( ) < 1 && * configuration. generate_random_corpus_ref ( ) {
289291 let mut generator = RandBytesGenerator :: new ( 64 ) ;
290292 state. generate_initial_inputs (
291293 & mut fuzzer,
292294 & mut executor,
293295 & mut generator,
294296 & mut manager,
295- * configuration. initial_random_corpus_size ( ) ,
297+ configuration. initial_random_corpus_size_deref ( ) ,
296298 ) ?;
297299 }
298300 }
@@ -366,7 +368,7 @@ impl Tsffs {
366368 }
367369
368370 pub fn get_testcase ( & mut self ) -> Result < Testcase > {
369- let testcase = if let Some ( testcase) = self . repro_testcase ( ) {
371+ let testcase = if let Some ( testcase) = self . repro_testcase_ref ( ) {
370372 debug ! ( self . as_conf_object( ) , "Using repro testcase" ) ;
371373 Testcase {
372374 testcase : testcase. clone ( ) ,
0 commit comments