Blame view

3rdparty/c-ares-1.18.1/test/ares-test-fuzz-name.c 602 Bytes
73ef4ff3   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <stddef.h>
  #include <stdlib.h>
  #include <string.h>
  
  #include "ares.h"
  // Include ares internal file for DNS protocol constants
  #include "ares_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, C_IN, T_AAAA, 1234, 0, &buf, &buflen, 1024);
    free(buf);
    free(name);
    return 0;
  }