| 427 | } |
| 428 | |
| 429 | void Fuzzer::RereadOutputCorpus(size_t MaxSize) { |
| 430 | if (Options.OutputCorpus.empty() || !Options.ReloadIntervalSec) |
| 431 | return; |
| 432 | std::vector<Unit> AdditionalCorpus; |
| 433 | std::vector<std::string> AdditionalCorpusPaths; |
| 434 | ReadDirToVectorOfUnits( |
| 435 | Options.OutputCorpus.c_str(), &AdditionalCorpus, |
| 436 | &EpochOfLastReadOfOutputCorpus, MaxSize, |
| 437 | /*ExitOnError*/ false, |
| 438 | (Options.Verbosity >= 2 ? &AdditionalCorpusPaths : nullptr)); |
| 439 | if (Options.Verbosity >= 2) |
| 440 | Printf("Reload: read %zd new units.\n", AdditionalCorpus.size()); |
| 441 | bool Reloaded = false; |
| 442 | for (size_t i = 0; i != AdditionalCorpus.size(); ++i) { |
| 443 | auto &U = AdditionalCorpus[i]; |
| 444 | if (U.size() > MaxSize) |
| 445 | U.resize(MaxSize); |
| 446 | if (!Corpus.HasUnit(U)) { |
| 447 | if (RunOne(U.data(), U.size())) { |
| 448 | CheckExitOnSrcPosOrItem(); |
| 449 | Reloaded = true; |
| 450 | if (Options.Verbosity >= 2) |
| 451 | Printf("Reloaded %s\n", AdditionalCorpusPaths[i].c_str()); |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | if (Reloaded) |
| 456 | PrintStats("RELOAD"); |
| 457 | } |
| 458 | |
| 459 | void Fuzzer::PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size) { |
| 460 | auto TimeOfUnit = |