Imported Upstream version 1.18.1
[platform/upstream/c-ares.git] / test / ares-test-fuzz-name.c
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "ares.h"
6 // Include ares internal file for DNS protocol constants
7 #include "ares_nameser.h"
8
9 // Entrypoint for Clang's libfuzzer, exercising query creation.
10 int LLVMFuzzerTestOneInput(const unsigned char *data,
11                            unsigned long size) {
12   // Null terminate the data.
13   char *name = malloc(size + 1);
14   name[size] = '\0';
15   memcpy(name, data, size);
16
17   unsigned char *buf = NULL;
18   int buflen = 0;
19   ares_create_query(name, C_IN, T_AAAA, 1234, 0, &buf, &buflen, 1024);
20   free(buf);
21   free(name);
22   return 0;
23 }