20 #include <sys/types.h>
28 if (stat(Path.c_str(), &St))
34 std::ifstream
T(Path);
35 if (ExitOnError && !T) {
36 Printf(
"No such directory: %s; exiting\n", Path.c_str());
41 size_t FileLen = T.tellg();
43 FileLen =
std::min(FileLen, MaxSize);
47 T.read(reinterpret_cast<char *>(Res.data()), FileLen);
52 std::ifstream
T(Path);
53 return std::string((std::istreambuf_iterator<char>(T)),
54 std::istreambuf_iterator<char>());
63 FILE *Out = fopen(Path.c_str(),
"w");
65 fwrite(U.data(),
sizeof(U[0]), U.size(), Out);
70 long *Epoch,
size_t MaxSize,
bool ExitOnError) {
71 long E = Epoch ? *Epoch : 0;
72 std::vector<std::string> Files;
75 for (
size_t i = 0; i < Files.size(); i++) {
79 if ((NumLoaded & (NumLoaded - 1)) == 0 && NumLoaded >= 1024)
80 Printf(
"Loaded %zd/%zd files from %s\n", NumLoaded, Files.size(), Path);
88 const std::string &FileName) {
95 FILE *NewOutputFile =
OpenFile(OutputFd,
"w");
98 if (
EF->__sanitizer_set_report_fd)
99 EF->__sanitizer_set_report_fd(
int DuplicateFile(int Fd)
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
void ListFilesInDirRecursive(const std::string &Dir, long *Epoch, std::vector< std::string > *V, bool TopDir)
std::string FileToString(const std::string &Path)
void ReadDirToVectorOfUnits(const char *Path, std::vector< Unit > *V, long *Epoch, size_t MaxSize, bool ExitOnError)
long GetEpoch(const std::string &Path)
FILE * OpenFile(int Fd, const char *Mode)
std::string DirPlusFile(const std::string &DirPath, const std::string &FileName)
intptr_t GetHandleFromFd(int fd)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
void CopyFileToErr(const std::string &Path)
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
void WriteToFile(const Unit &U, const std::string &Path)
Unit FileToVector(const std::string &Path, size_t MaxSize, bool ExitOnError)
void DiscardOutput(int Fd)
std::vector< uint8_t > Unit
Printf(" # Score: %d, Used: %d\n", Scores[i], Usages[i])