Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / deps / grpc / third_party / cares / cares / test / ares-test-fuzz-name.c
diff --git a/legacy-libs/grpc-cloned/deps/grpc/third_party/cares/cares/test/ares-test-fuzz-name.c b/legacy-libs/grpc-cloned/deps/grpc/third_party/cares/cares/test/ares-test-fuzz-name.c
new file mode 100644 (file)
index 0000000..378da37
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ares.h"
+// Include ares internal file for DNS protocol constants
+#include "nameser.h"
+
+// Entrypoint for Clang's libfuzzer, exercising query creation.
+int LLVMFuzzerTestOneInput(const unsigned char *data,
+                           unsigned long size) {
+  // Null terminate the data.
+  char *name = malloc(size + 1);
+  name[size] = '\0';
+  memcpy(name, data, size);
+
+  unsigned char *buf = NULL;
+  int buflen = 0;
+  ares_create_query(name, ns_c_in, ns_t_aaaa, 1234, 0, &buf, &buflen, 1024);
+  free(buf);
+  free(name);
+  return 0;
+}