Coverage Report

Created: 2025-10-10 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fuzz_util.c
Line
Count
Source
1
/* Copyright 2021 Google LLC
2
Licensed under the Apache License, Version 2.0 (the "License");
3
you may not use this file except in compliance with the License.
4
You may obtain a copy of the License at
5
      http://www.apache.org/licenses/LICENSE-2.0
6
Unless required by applicable law or agreed to in writing, software
7
distributed under the License is distributed on an "AS IS" BASIS,
8
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
See the License for the specific language governing permissions and
10
limitations under the License.
11
*/
12
13
#include "fuzz_header.h"
14
15
830
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
16
  // init fuzz garbage collector
17
830
  gb_init();
18
19
830
  int succ = init_daemon(&data, &size);
20
830
  if (succ == 0) {
21
513
    char *t1 = gb_get_len_null_terminated(&data, &size, MAXDNAME);
22
513
    char *t2 = gb_get_len_null_terminated(&data, &size, MAXDNAME);
23
513
    if (t1 != NULL && t2 != NULL) {
24
25
      // Util logic
26
513
      hostname_isequal(t1, t2);
27
28
513
      legal_hostname(t1);
29
513
      char *tmp = canonicalise(t2, NULL);
30
513
      if (tmp != NULL) {
31
27
        free(tmp);
32
27
      }
33
34
513
      char *tmp_out = (char *)malloc(30);
35
513
      int mac_type;
36
513
      parse_hex(t1, (unsigned char *)tmp_out, 30, NULL, NULL);
37
513
      parse_hex(t1, (unsigned char *)tmp_out, 30, NULL, &mac_type);
38
513
      free(tmp_out);
39
40
513
      wildcard_match(t1, t2);
41
513
      if (strlen(t1) < strlen(t2)) {
42
324
        wildcard_matchn(t1, t2, strlen(t1));
43
324
      } else {
44
189
        wildcard_matchn(t1, t2, strlen(t2));
45
189
      }
46
513
      hostname_issubdomain(t1, t2);
47
48
513
      union all_addr addr1;
49
513
      memset(&addr1, 0, sizeof(union all_addr));
50
513
      is_name_synthetic(0, t1, &addr1);
51
52
      //if (size > sizeof(struct dns_header)) {
53
      //  hash_questions(data, size, t2);
54
55
      //  rrfilter(data, size, 0);
56
      //}
57
513
    }
58
59
    //fuzz_blockdata_cleanup();
60
513
  }
61
62
  // cleanup
63
830
  gb_cleanup();
64
65
830
  return 0;
66
830
}