diff options
author | Kostya Serebryany <kcc@google.com> | 2016-10-08 23:24:45 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-10-08 23:24:45 +0000 |
commit | c5325ed29d01d2d24121fcc57249c7939d085814 (patch) | |
tree | b75d5abe290ada0a9061898b99365dc862eca895 /llvm/lib/Fuzzer/FuzzerLoop.cpp | |
parent | 8ec7b4f588fb1bf00672318d3e313480726dd8ef (diff) | |
download | bcm5719-llvm-c5325ed29d01d2d24121fcc57249c7939d085814.tar.gz bcm5719-llvm-c5325ed29d01d2d24121fcc57249c7939d085814.zip |
[libFuzzer] when shrinking the corpus, delete evicted files previously created by the current process
llvm-svn: 283682
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerLoop.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index be006ce7cdc..1b5e0265e13 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -386,7 +386,8 @@ void Fuzzer::RereadOutputCorpus(size_t MaxSize) { if (Options.OutputCorpus.empty() || !Options.ReloadIntervalSec) return; std::vector<Unit> AdditionalCorpus; ReadDirToVectorOfUnits(Options.OutputCorpus.c_str(), &AdditionalCorpus, - &EpochOfLastReadOfOutputCorpus, MaxSize); + &EpochOfLastReadOfOutputCorpus, MaxSize, + /*ExitOnError*/ false); if (Options.Verbosity >= 2) Printf("Reload: read %zd new units.\n", AdditionalCorpus.size()); bool Reloaded = false; @@ -605,9 +606,9 @@ void Fuzzer::Merge(const std::vector<std::string> &Corpora) { assert(MaxInputLen > 0); UnitVector Initial, Extra; - ReadDirToVectorOfUnits(Corpora[0].c_str(), &Initial, nullptr, MaxInputLen); + ReadDirToVectorOfUnits(Corpora[0].c_str(), &Initial, nullptr, MaxInputLen, true); for (auto &C : ExtraCorpora) - ReadDirToVectorOfUnits(C.c_str(), &Extra, nullptr, MaxInputLen); + ReadDirToVectorOfUnits(C.c_str(), &Extra, nullptr, MaxInputLen, true); if (!Initial.empty()) { Printf("=== Minimizing the initial corpus of %zd units\n", Initial.size()); @@ -685,8 +686,8 @@ void Fuzzer::MutateAndTestOne() { StartTraceRecording(); II.NumExecutedMutations++; if (size_t NumFeatures = RunOne(CurrentUnitData, Size)) { - Corpus.AddToCorpus({CurrentUnitData, CurrentUnitData + Size}, - NumFeatures); + Corpus.AddToCorpus({CurrentUnitData, CurrentUnitData + Size}, NumFeatures, + /*MayDeleteFile=*/true); ReportNewCoverage(&II, {CurrentUnitData, CurrentUnitData + Size}); CheckExitOnItem(); } @@ -711,7 +712,7 @@ void Fuzzer::Loop() { if (duration_cast<seconds>(Now - LastCorpusReload).count() >= Options.ReloadIntervalSec) { RereadOutputCorpus(MaxInputLen); - LastCorpusReload = Now; + LastCorpusReload = system_clock::now(); } if (TotalNumberOfRuns >= Options.MaxNumberOfRuns) break; |