@@ -210,6 +210,12 @@ def _corpus_source(run_dir: Path, run: dict, target: NativeTarget) -> Path:
210210 return _safe_run_file (run_root , run ["input" ]["source" ], "native corpus" )
211211
212212
213+ def _corpus_directory (run_dir : Path , run : dict , target : NativeTarget ) -> Path :
214+ # Resolve the seed before _process changes the child's cwd. libFuzzer treats
215+ # a directory argument as a fuzzing corpus and a file argument as replay.
216+ return _corpus_source (run_dir , run , target ).parent
217+
218+
213219def _safe_run_file (run_root : Path , value : object , label : str ) -> Path :
214220 if not isinstance (value , str ):
215221 raise ValueError (f"{ label } path must be a string" )
@@ -303,7 +309,11 @@ def _case(
303309 },
304310 }
305311 try :
306- source = _corpus_source (run_dir , run , target ) if target .engine == "coverage-guided" and target .binary_name else None
312+ corpus = (
313+ _corpus_directory (run_dir , run , target )
314+ if target .engine == "coverage-guided" and target .binary_name
315+ else None
316+ )
307317 except ValueError as error :
308318 return {
309319 ** base ,
@@ -322,11 +332,11 @@ def _case(
322332 if target .engine == "coverage-guided" and target .binary_name is None :
323333 command = ["cargo" , "fuzz" , "run" , target .official_target , "--" , * limits ]
324334 elif target .engine == "coverage-guided" :
325- assert source is not None
335+ assert corpus is not None
326336 command = [
327337 str (binary ), "-print_final_stats=1" ,
328338 f"-timeout={ _fuzz_seconds (duration_seconds )} " ,
329- * limits , source . as_posix (),
339+ * limits ,
330340 ]
331341 else :
332342 command = [
@@ -337,6 +347,8 @@ def _case(
337347 ]
338348 if target .engine == "coverage-guided" and fixture :
339349 command .append ("-runs=1" )
350+ if corpus is not None :
351+ command .append (corpus .as_posix ())
340352 process , stdout , stderr = _process (
341353 command , work_dir , duration_seconds + 5 , output_budget_bytes = _NATIVE_OUTPUT_BUDGET_BYTES
342354 )
@@ -357,8 +369,8 @@ def _case(
357369 }
358370 if binary is not None :
359371 details ["binary_sha256" ] = _sha256 (binary )
360- if source is not None :
361- details ["corpus" ] = source .relative_to (run_root ).as_posix ()
372+ if corpus is not None :
373+ details ["corpus" ] = corpus .relative_to (run_root ).as_posix ()
362374 result = {
363375 ** base ,
364376 "observed" : observed ,
0 commit comments