#include "FuzzerCorpus.h"
#include "FuzzerIO.h"
#include "FuzzerInternal.h"
#include "FuzzerMutate.h"
#include "FuzzerPlatform.h"
#include "FuzzerRandom.h"
#include "FuzzerTracePC.h"
#include <algorithm>
#include <cstring>
#include <memory>
#include <mutex>
#include <set>
#if defined(__has_include)
#if __has_include(<sanitizer / lsan_interface.h>)
#include <sanitizer/lsan_interface.h>
#endif
#endif
#define NO_SANITIZE_MEMORY
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#undef NO_SANITIZE_MEMORY
#define NO_SANITIZE_MEMORY …
#endif
#endif
namespace fuzzer {
static const size_t kMaxUnitSizeToPrint = …;
thread_local bool Fuzzer::IsMyThread;
bool RunningUserCallback = …;
static Fuzzer *F;
struct MallocFreeTracer { … };
static MallocFreeTracer AllocTracer;
class TraceLock { … };
ATTRIBUTE_NO_SANITIZE_MEMORY
void MallocHook(const volatile void *ptr, size_t size) { … }
ATTRIBUTE_NO_SANITIZE_MEMORY
void FreeHook(const volatile void *ptr) { … }
void Fuzzer::HandleMalloc(size_t Size) { … }
Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
const FuzzingOptions &Options)
: … { … }
void Fuzzer::AllocateCurrentUnitData() { … }
void Fuzzer::StaticDeathCallback() { … }
void Fuzzer::DumpCurrentUnit(const char *Prefix) { … }
NO_SANITIZE_MEMORY
void Fuzzer::DeathCallback() { … }
void Fuzzer::StaticAlarmCallback() { … }
void Fuzzer::StaticCrashSignalCallback() { … }
void Fuzzer::StaticExitCallback() { … }
void Fuzzer::StaticInterruptCallback() { … }
void Fuzzer::StaticGracefulExitCallback() { … }
void Fuzzer::StaticFileSizeExceedCallback() { … }
void Fuzzer::CrashCallback() { … }
void Fuzzer::ExitCallback() { … }
void Fuzzer::MaybeExitGracefully() { … }
int Fuzzer::InterruptExitCode() { … }
void Fuzzer::InterruptCallback() { … }
NO_SANITIZE_MEMORY
void Fuzzer::AlarmCallback() { … }
void Fuzzer::RssLimitCallback() { … }
void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units,
size_t Features) { … }
void Fuzzer::PrintFinalStats() { … }
void Fuzzer::SetMaxInputLen(size_t MaxInputLen) { … }
void Fuzzer::SetMaxMutationLen(size_t MaxMutationLen) { … }
void Fuzzer::CheckExitOnSrcPosOrItem() { … }
void Fuzzer::RereadOutputCorpus(size_t MaxSize) { … }
void Fuzzer::PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size) { … }
static void WriteFeatureSetToFile(const std::string &FeaturesDir,
const std::string &FileName,
const std::vector<uint32_t> &FeatureSet) { … }
static void RenameFeatureSetFile(const std::string &FeaturesDir,
const std::string &OldFile,
const std::string &NewFile) { … }
static void WriteEdgeToMutationGraphFile(const std::string &MutationGraphFile,
const InputInfo *II,
const InputInfo *BaseII,
const std::string &MS) { … }
bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,
InputInfo *II, bool ForceAddToCorpus,
bool *FoundUniqFeatures) { … }
void Fuzzer::TPCUpdateObservedPCs() { … }
size_t Fuzzer::GetCurrentUnitInFuzzingThead(const uint8_t **Data) const { … }
void Fuzzer::CrashOnOverwrittenData() { … }
static bool LooseMemeq(const uint8_t *A, const uint8_t *B, size_t Size) { … }
ATTRIBUTE_NOINLINE bool Fuzzer::ExecuteCallback(const uint8_t *Data,
size_t Size) { … }
std::string Fuzzer::WriteToOutputCorpus(const Unit &U) { … }
void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) { … }
void Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) { … }
void Fuzzer::ReportNewCoverage(InputInfo *II, const Unit &U) { … }
void Fuzzer::TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size,
bool DuringInitialCorpusExecution) { … }
void Fuzzer::MutateAndTestOne() { … }
void Fuzzer::PurgeAllocator() { … }
void Fuzzer::ReadAndExecuteSeedCorpora(std::vector<SizedFile> &CorporaFiles) { … }
void Fuzzer::Loop(std::vector<SizedFile> &CorporaFiles) { … }
void Fuzzer::MinimizeCrashLoop(const Unit &U) { … }
}
extern "C" {
ATTRIBUTE_INTERFACE size_t
LLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize) { … }
}