xref: /netbsd-src/external/mpl/bind/dist/fuzz/dns_name_fromtext_target.c (revision f3cfa6f6ce31685c6c4a758bc430e69eb99f50a4)
1 /*	$NetBSD: dns_name_fromtext_target.c,v 1.2 2019/01/09 16:55:11 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
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 http://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 #include <isc/buffer.h>
17 #include <isc/util.h>
18 #include <dns/fixedname.h>
19 #include <dns/name.h>
20 
21 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
22 
23 int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
24 {
25     isc_buffer_t buf;
26     isc_result_t result;
27     dns_fixedname_t origin;
28     char *de_const;
29 
30     if (size < 5) {
31 	    return 0;
32     }
33 
34     dns_fixedname_init(&origin);
35     DE_CONST(data, de_const);
36     isc_buffer_init(&buf, (void *)de_const, size);
37     isc_buffer_add(&buf, size);
38     result = dns_name_fromtext(dns_fixedname_name(&origin), &buf, dns_rootname, 0, NULL);
39     UNUSED(result);
40     return 0;
41 }
42