main.cc 592 B

12345678910111213141516171819202122
  1. #include <cassert>
  2. #include <fstream>
  3. #include <vector>
  4. #include "fuzzer-common.h"
  5. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
  6. int main(int argc, char** argv) {
  7. for (int i = 1; i < argc; ++i) {
  8. std::ifstream in(argv[i]);
  9. assert(in);
  10. in.seekg(0, std::ios_base::end);
  11. const auto size = in.tellg();
  12. assert(size >= 0);
  13. in.seekg(0, std::ios_base::beg);
  14. std::vector<char> buf(static_cast<size_t>(size));
  15. in.read(buf.data(), size);
  16. assert(in.gcount() == size);
  17. LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size());
  18. }
  19. }