summaryrefslogtreecommitdiff
path: root/test/ares-fuzz.cc
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-11-09 11:22:24 +0900
committerYu Jiung <jiung.yu@samsung.com>2016-11-09 11:22:24 +0900
commitf57d349bba373ddb713a249cb2866198346ae011 (patch)
tree54b98d64d1dfb0667097ce326a2a3d32dfe060b0 /test/ares-fuzz.cc
parent4486382682f22650e6de23a607d92dbccc3c9aee (diff)
parenteb886f120599b2a184db20b527db6dfdfcb7852e (diff)
downloadc-ares-f57d349bba373ddb713a249cb2866198346ae011.tar.gz
c-ares-f57d349bba373ddb713a249cb2866198346ae011.tar.bz2
c-ares-f57d349bba373ddb713a249cb2866198346ae011.zip
Merge branch 'upstream' into tizen
Conflicts: ares_set_local_dev.3 ares_set_servers_csv.3 Change-Id: I1da63c678df60657e903fd4917f07784bd37ce94
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;
+}