Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 1 | #include <iostream> |
| 2 | #include "flatbuffers/util.h" |
| 3 | |
| 4 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); |
| 5 | |
| 6 | int main(int argc, char *argv[]) { |
| 7 | if (argc < 2) { |
| 8 | std::cerr << "Usage: scalar_debug <path to fuzzer crash file>\n"; |
| 9 | return 0; |
| 10 | } |
| 11 | std::string crash_file_name(argv[1]); |
| 12 | std::string crash_file_data; |
| 13 | auto done = |
| 14 | flatbuffers::LoadFile(crash_file_name.c_str(), true, &crash_file_data); |
| 15 | if (!done) { |
| 16 | std::cerr << "Can not load file: '" << crash_file_name << "'"; |
| 17 | return -1; |
| 18 | } |
| 19 | if (crash_file_data.size() < 3) { |
| 20 | std::cerr << "Invalid file data: '" << crash_file_data << "'"; |
| 21 | return -2; |
| 22 | } |
| 23 | auto rc = LLVMFuzzerTestOneInput( |
| 24 | reinterpret_cast<const uint8_t *>(crash_file_data.data()), |
| 25 | crash_file_data.size()); |
| 26 | std::cout << "LLVMFuzzerTestOneInput finished with code " << rc; |
| 27 | return rc; |
| 28 | } |