Debian Codegraph @

fuzz/dns_name_fromtext_target.c

raw
1 /*
2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3 *
4 * SPDX-License-Identifier: MPL-2.0
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * See the COPYRIGHT file distributed with this work for additional
11 * information regarding copyright ownership.
12 */
13
14 #include <stddef.h>
15 #include <stdint.h>
16
17 #include <isc/buffer.h>
18 #include <isc/util.h>
19
20 #include <dns/fixedname.h>
21 #include <dns/name.h>
22
23 #include "fuzz.h"
24
25 bool debug = false;
26
27 int
28 LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
29 return 0;
30 }
31
32 int
33 LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
34 isc_buffer_t buf;
35 isc_result_t result;
36 dns_fixedname_t origin;
37
38 dns_fixedname_init(&origin);
39
40 isc_buffer_constinit(&buf, data, size);
41 isc_buffer_add(&buf, size);
42 isc_buffer_setactive(&buf, size);
43
44 result = dns_name_fromtext(dns_fixedname_name(&origin), &buf,
45 dns_rootname, 0, NULL);
46 if (debug) {
47 fprintf(stderr, "dns_name_fromtext: %s\n",
48 isc_result_totext(result));
49 }
50 return 0;
51 }