Coverage Report

Created: 2023-09-25 07:14

/src/c-ares/test/ares-test-fuzz-name.c
Line
Count
Source
1
/*
2
 * Copyright (C) The c-ares project
3
 *
4
 * Permission to use, copy, modify, and distribute this
5
 * software and its documentation for any purpose and without
6
 * fee is hereby granted, provided that the above copyright
7
 * notice appear in all copies and that both that copyright
8
 * notice and this permission notice appear in supporting
9
 * documentation, and that the name of M.I.T. not be used in
10
 * advertising or publicity pertaining to distribution of the
11
 * software without specific, written prior permission.
12
 * M.I.T. makes no representations about the suitability of
13
 * this software for any purpose.  It is provided "as is"
14
 * without express or implied warranty.
15
 *
16
 * SPDX-License-Identifier: MIT
17
 */
18
#include <stddef.h>
19
#include <stdlib.h>
20
#include <string.h>
21
22
#include "ares.h"
23
// Include ares internal file for DNS protocol constants
24
#include "ares_nameser.h"
25
26
// Entrypoint for Clang's libfuzzer, exercising query creation.
27
int LLVMFuzzerTestOneInput(const unsigned char *data,
28
186
                           unsigned long size) {
29
  // Null terminate the data.
30
186
  char *name = malloc(size + 1);
31
186
  name[size] = '\0';
32
186
  memcpy(name, data, size);
33
34
186
  unsigned char *buf = NULL;
35
186
  int buflen = 0;
36
186
  ares_create_query(name, C_IN, T_AAAA, 1234, 0, &buf, &buflen, 1024);
37
186
  free(buf);
38
186
  free(name);
39
186
  return 0;
40
186
}