Files
fmt/test/fuzzing/main.cc
T

23 lines
592 B
C++
Raw Normal View History

2019-06-30 09:11:13 +02:00
#include <cassert>
#include <fstream>
#include <vector>
2020-10-11 08:30:14 -07:00
#include "fuzzer-common.h"
2019-06-30 09:11:13 +02:00
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
int main(int argc, char** argv) {
2019-06-30 09:11:13 +02:00
for (int i = 1; i < argc; ++i) {
std::ifstream in(argv[i]);
assert(in);
in.seekg(0, std::ios_base::end);
const auto size = in.tellg();
assert(size >= 0);
2019-06-30 09:11:13 +02:00
in.seekg(0, std::ios_base::beg);
std::vector<char> buf(static_cast<size_t>(size));
in.read(buf.data(), size);
assert(in.gcount() == size);
2020-10-13 08:08:48 -07:00
LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size());
2019-06-30 09:11:13 +02:00
}
}