summaryrefslogtreecommitdiff
path: root/test/ares-fuzz.cc
blob: 4680b727c2d62d5a45732e1def440d3a4dec6d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// General driver to allow command-line fuzzer (i.e. afl) to
// fuzz the libfuzzer entrypoint.
#include <stdio.h>
#include <unistd.h>

#include <vector>

extern "C" void LLVMFuzzerTestOneInput(const unsigned char *data,
                                       unsigned long size);
int main() {
  std::vector<unsigned char> input;
  while (true) {
    unsigned char buffer[1024];
    int len = read(fileno(stdin), buffer, sizeof(buffer));
    if (len <= 0) break;
    input.insert(input.end(), buffer, buffer + len);
  }
  LLVMFuzzerTestOneInput(input.data(), input.size());
  return 0;
}