MCPcopy Create free account
hub / github.com/HexHive/NASS / RunOne

Method RunOne

fuzz/libfuzzer/FuzzerLoop.cpp:522–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520}
521
522bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,
523 InputInfo *II, bool ForceAddToCorpus,
524 bool *FoundUniqFeatures) {
525 if (!Size)
526 return false;
527 // Largest input length should be INT_MAX.
528 assert(Size < std::numeric_limits<uint32_t>::max());
529
530 if(!ExecuteCallback(Data, Size)) return false;
531 auto TimeOfUnit = duration_cast<microseconds>(UnitStopTime - UnitStartTime);
532
533 UniqFeatureSetTmp.clear();
534 size_t FoundUniqFeaturesOfII = 0;
535 size_t NumUpdatesBefore = Corpus.NumFeatureUpdates();
536 TPC.CollectFeatures([&](uint32_t Feature) {
537 if (Corpus.AddFeature(Feature, static_cast<uint32_t>(Size), Options.Shrink))
538 UniqFeatureSetTmp.push_back(Feature);
539 if (Options.Entropic)
540 Corpus.UpdateFeatureFrequency(II, Feature);
541 if (Options.ReduceInputs && II && !II->NeverReduce)
542 if (std::binary_search(II->UniqFeatureSet.begin(),
543 II->UniqFeatureSet.end(), Feature))
544 FoundUniqFeaturesOfII++;
545 });
546 if (FoundUniqFeatures)
547 *FoundUniqFeatures = FoundUniqFeaturesOfII;
548 PrintPulseAndReportSlowInput(Data, Size);
549 size_t NumNewFeatures = Corpus.NumFeatureUpdates() - NumUpdatesBefore;
550 if (NumNewFeatures || ForceAddToCorpus) {
551 TPC.UpdateObservedPCs();
552 auto NewII =
553 Corpus.AddToCorpus({Data, Data + Size}, NumNewFeatures, MayDeleteFile,
554 TPC.ObservedFocusFunction(), ForceAddToCorpus,
555 TimeOfUnit, UniqFeatureSetTmp, DFT, II);
556 WriteFeatureSetToFile(Options.FeaturesDir, Sha1ToString(NewII->Sha1),
557 NewII->UniqFeatureSet);
558 WriteEdgeToMutationGraphFile(Options.MutationGraphFile, NewII, II,
559 MD.MutationSequence());
560 return true;
561 }
562 if (II && FoundUniqFeaturesOfII &&
563 II->DataFlowTraceForFocusFunction.empty() &&
564 FoundUniqFeaturesOfII == II->UniqFeatureSet.size() &&
565 II->U.size() > Size) {
566 auto OldFeaturesFile = Sha1ToString(II->Sha1);
567 Corpus.Replace(II, {Data, Data + Size}, TimeOfUnit);
568 RenameFeatureSetFile(Options.FeaturesDir, OldFeaturesFile,
569 Sha1ToString(II->Sha1));
570 return true;
571 }
572 return false;
573}
574
575void Fuzzer::TPCUpdateObservedPCs() { TPC.UpdateObservedPCs(); }
576

Callers

nothing calls this directly

Calls 15

WriteFeatureSetToFileFunction · 0.85
RenameFeatureSetFileFunction · 0.85
NumFeatureUpdatesMethod · 0.80
CollectFeaturesMethod · 0.80
AddFeatureMethod · 0.80
UpdateObservedPCsMethod · 0.80
AddToCorpusMethod · 0.80
ObservedFocusFunctionMethod · 0.80
MutationSequenceMethod · 0.80
ReplaceMethod · 0.80
Sha1ToStringFunction · 0.70

Tested by

no test coverage detected