You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

standalone_runner.cc 877 B

12345678910111213141516171819202122232425
  1. #include <cassert>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <vector>
  5. // Forward declare the "fuzz target" interface.
  6. // We deliberately keep this inteface simple and header-free.
  7. extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
  8. int main(int argc, char **argv) {
  9. for (int i = 1; i < argc; i++) {
  10. std::ifstream in(argv[i]);
  11. in.seekg(0, in.end);
  12. size_t length = in.tellg();
  13. in.seekg(0, in.beg);
  14. std::cout << "Reading " << length << " bytes from " << argv[i] << std::endl;
  15. // Allocate exactly length bytes so that we reliably catch buffer overflows.
  16. std::vector<char> bytes(length);
  17. in.read(bytes.data(), bytes.size());
  18. assert(in);
  19. LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()),
  20. bytes.size());
  21. std::cout << "Execution successful" << std::endl;
  22. }
  23. }