fuzzer_main.cpp 918 B

12345678910111213141516171819202122232425262728293031323334
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2018
  3. // MIT License
  4. // This file is NOT use by Google's OSS fuzz
  5. // I only use it to reproduce the bugs found
  6. #include <stdint.h>
  7. #include <fstream>
  8. #include <iostream>
  9. #include <string>
  10. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
  11. std::string read(const char* path) {
  12. std::ifstream file(path);
  13. return std::string(std::istreambuf_iterator<char>(file),
  14. std::istreambuf_iterator<char>());
  15. }
  16. int main(int argc, const char* argv[]) {
  17. if (argc < 2) {
  18. std::cerr << "Usage: msgpack_fuzzer files" << std::endl;
  19. return 1;
  20. }
  21. for (int i = 1; i < argc; i++) {
  22. std::cout << "Loading " << argv[i] << std::endl;
  23. std::string buffer = read(argv[i]);
  24. LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(buffer.data()),
  25. buffer.size());
  26. }
  27. return 0;
  28. }