summaryrefslogtreecommitdiff
path: root/test/ares-fuzz.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/ares-fuzz.cc')
-rw-r--r--test/ares-fuzz.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ares-fuzz.cc b/test/ares-fuzz.cc
new file mode 100644
index 0000000..4680b72
--- /dev/null
+++ b/test/ares-fuzz.cc
@@ -0,0 +1,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;
+}