• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <iostream>
2 #include <assert.h>
3 
4 #include "flatbuffers/util.h"
5 
6 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
7 
main(int argc,char * argv[])8 int main(int argc, char *argv[]) {
9   if (argc < 2) {
10     std::cerr << "Usage: monster_debug <path to fuzzer crash file>\n";
11     return 0;
12   }
13   std::string crash_file_name(argv[1]);
14   std::string crash_file_data;
15   auto done =
16       flatbuffers::LoadFile(crash_file_name.c_str(), true, &crash_file_data);
17   if (!done) {
18     std::cerr << "Can not load file: '" << crash_file_name << "'";
19     return -1;
20   }
21   if (crash_file_data.size() < 3) {
22     std::cerr << "Invalid file data: '" << crash_file_data << "'";
23     return -2;
24   }
25   auto rc = LLVMFuzzerTestOneInput(
26       reinterpret_cast<const uint8_t *>(crash_file_data.data()),
27       crash_file_data.size());
28   std::cout << "LLVMFuzzerTestOneInput finished with code " << rc << "\n\n";
29   return rc;
30 }
31