void ShuffleCorpus(UnitVector *V);
void TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size,
bool DuringInitialCorpusExecution);
- void AddToCorpusAndMaybeRerun(const Unit &U);
+ void AddToCorpus(const Unit &U);
void CheckExitOnSrcPos();
// Trace-based fuzzing: we run a unit with some kind of tracing
}
}
-void Fuzzer::AddToCorpusAndMaybeRerun(const Unit &U) {
- CheckExitOnSrcPos();
- if (TPC.GetTotalPCCoverage()) {
- TPC.ResetMaps();
- TPC.ResetGuards();
- ExecuteCallback(U.data(), U.size());
- TPC.FinalizeTrace();
- }
- Corpus.AddToCorpus(U);
-}
-
void Fuzzer::RereadOutputCorpus(size_t MaxSize) {
if (Options.OutputCorpus.empty() || !Options.Reload) return;
std::vector<Unit> AdditionalCorpus;
&EpochOfLastReadOfOutputCorpus, MaxSize);
if (Options.Verbosity >= 2)
Printf("Reload: read %zd new units.\n", AdditionalCorpus.size());
- for (auto &X : AdditionalCorpus) {
- if (X.size() > MaxSize)
- X.resize(MaxSize);
- if (!Corpus.HasUnit(X)) {
- if (RunOne(X)) {
- AddToCorpusAndMaybeRerun(X);
+ for (auto &U : AdditionalCorpus) {
+ if (U.size() > MaxSize)
+ U.resize(MaxSize);
+ if (!Corpus.HasUnit(U)) {
+ if (RunOne(U)) {
+ Corpus.AddToCorpus(U);
PrintStats("RELOAD");
}
}
for (const auto &U : *InitialCorpus) {
if (RunOne(U)) {
- AddToCorpusAndMaybeRerun(U);
+ Corpus.AddToCorpus(U);
if (Options.Verbosity >= 2)
Printf("NEW0: %zd L %zd\n", MaxCoverage.BlockCoverage, U.size());
}
ExecuteCallback(Data, Size);
bool Res = RecordMaxCoverage(&MaxCoverage);
+ CheckExitOnSrcPos();
auto TimeOfUnit =
duration_cast<seconds>(UnitStopTime - UnitStartTime).count();
if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1)) &&
WriteToOutputCorpus(U);
NumberOfNewUnitsAdded++;
PrintNewPCs();
- AddToCorpusAndMaybeRerun(U);
}
// Finds minimal number of units in 'Extra' that add coverage to 'Initial'.
if (i == 0)
StartTraceRecording();
II.NumExecutedMutations++;
- if (RunOne(CurrentUnitData, Size))
+ if (RunOne(CurrentUnitData, Size)) {
+ Corpus.AddToCorpus({CurrentUnitData, CurrentUnitData + Size});
ReportNewCoverage(&II, {CurrentUnitData, CurrentUnitData + Size});
+ }
StopTraceRecording();
TryDetectingAMemoryLeak(CurrentUnitData, Size,
/*DuringInitialCorpusExecution*/ false);