#include #include #include #include // view data as a byte pointer template inline const std::uint8_t* as_bytes(const T* data) { return static_cast(static_cast(data)); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size); int main(int argc, char* argv[]) { for (int i = 1; i < argc; ++i) { std::ifstream in(argv[i]); assert(in); in.seekg(0, std::ios_base::end); const auto pos = in.tellg(); assert(pos >= 0); in.seekg(0, std::ios_base::beg); std::vector buf(static_cast(pos)); in.read(buf.data(), static_cast(buf.size())); assert(in.gcount() == pos); LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size()); } }