@@ -8,16 +8,16 @@ use core::{marker::PhantomData, time::Duration};
8
8
use std:: path:: { Path , PathBuf } ;
9
9
10
10
use libafl_bolts:: {
11
- Named , current_time,
11
+ current_time,
12
12
fs:: find_new_files_rec,
13
13
shmem:: { ShMem , ShMemProvider } ,
14
+ Named ,
14
15
} ;
15
16
use serde:: { Deserialize , Serialize } ;
16
17
17
18
use crate :: {
18
- Error , HasMetadata , HasNamedMetadata ,
19
19
corpus:: { Corpus , CorpusId , HasCurrentCorpusId } ,
20
- events:: { Event , EventConfig , EventFirer , EventWithStats , llmp :: LlmpEventConverter } ,
20
+ events:: { llmp :: LlmpEventConverter , Event , EventConfig , EventFirer , EventWithStats } ,
21
21
executors:: { Executor , ExitKind , HasObservers } ,
22
22
fuzzer:: { Evaluator , EvaluatorObservers , ExecutionProcessor , HasObjective } ,
23
23
inputs:: { Input , InputConverter } ,
@@ -26,6 +26,7 @@ use crate::{
26
26
HasCorpus , HasCurrentTestcase , HasExecutions , HasRand , HasSolutions ,
27
27
MaybeHasClientPerfMonitor , Stoppable ,
28
28
} ,
29
+ Error , HasMetadata , HasNamedMetadata ,
29
30
} ;
30
31
31
32
/// Default name for `SyncFromDiskStage`; derived from AFL++
@@ -75,7 +76,7 @@ impl<CB, E, EM, I, S, Z> Named for SyncFromDiskStage<CB, E, EM, I, S, Z> {
75
76
76
77
impl < CB , E , EM , I , S , Z > Stage < E , EM , S , Z > for SyncFromDiskStage < CB , E , EM , I , S , Z >
77
78
where
78
- CB : FnMut ( & mut Z , & mut S , & Path ) -> Result < I , Error > ,
79
+ CB : FnMut ( & mut Z , & mut S , & Path ) -> Result < Option < I > , Error > ,
79
80
Z : Evaluator < E , EM , I , S > ,
80
81
S : HasCorpus < I >
81
82
+ HasRand
@@ -134,6 +135,9 @@ where
134
135
. unwrap ( )
135
136
. left_to_sync
136
137
. retain ( |p| p != & path) ;
138
+ let Some ( input) = input else {
139
+ continue ;
140
+ } ;
137
141
log:: debug!( "Syncing and evaluating {path:?}" ) ;
138
142
fuzzer. evaluate_input ( state, executor, manager, & input) ?;
139
143
}
@@ -174,7 +178,7 @@ impl<CB, E, EM, I, S, Z> SyncFromDiskStage<CB, E, EM, I, S, Z> {
174
178
}
175
179
176
180
/// Function type when the callback in `SyncFromDiskStage` is not a lambda
177
- pub type SyncFromDiskFunction < I , S , Z > = fn ( & mut Z , & mut S , & Path ) -> Result < I , Error > ;
181
+ pub type SyncFromDiskFunction < I , S , Z > = fn ( & mut Z , & mut S , & Path ) -> Result < Option < I > , Error > ;
178
182
179
183
impl < E , EM , I , S , Z > SyncFromDiskStage < SyncFromDiskFunction < I , S , Z > , E , EM , I , S , Z >
180
184
where
@@ -185,12 +189,15 @@ where
185
189
/// Creates a new [`SyncFromDiskStage`] invoking `Input::from_file` to load inputs
186
190
#[ must_use]
187
191
pub fn with_from_file ( sync_dirs : Vec < PathBuf > , interval : Duration ) -> Self {
188
- fn load_callback < I , S , Z > ( _: & mut Z , _: & mut S , p : & Path ) -> Result < I , Error >
192
+ fn load_callback < I , S , Z > ( _: & mut Z , _: & mut S , p : & Path ) -> Result < Option < I > , Error >
189
193
where
190
194
I : Input ,
191
195
S : HasCorpus < I > ,
192
196
{
193
- Input :: from_file ( p)
197
+ match Input :: from_file ( p) {
198
+ Err ( err) => Err ( err) ,
199
+ Ok ( input) => Ok ( Some ( input) ) ,
200
+ }
194
201
}
195
202
Self {
196
203
interval,
0 commit comments