File: main.cpp

package info (click to toggle)
simdjson 4.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,936 kB
  • sloc: cpp: 171,612; ansic: 19,122; sh: 1,126; python: 842; makefile: 47; ruby: 25; javascript: 13
file content (23 lines) | stat: -rw-r--r-- 639 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cassert>
#include <fstream>
#include <sstream>
#include <vector>
#include "FuzzUtils.h"



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<char> buf(static_cast<std::size_t>(pos));
    in.read(buf.data(), static_cast<long>(buf.size()));
    assert(in.gcount() == pos);
    LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size());
  }
}