xref: /netbsd-src/external/mpl/bind/dist/fuzz/fuzz.h (revision 5dd36a3bc8bf2a9dec29ceb6349550414570c447)
1 /*	$NetBSD: fuzz.h,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 <config.h>
15 
16 #include <stdbool.h>
17 #include <stddef.h>
18 #include <stdint.h>
19 
20 #include <isc/lang.h>
21 #include <isc/mem.h>
22 #include <isc/once.h>
23 #include <isc/types.h>
24 #include <isc/util.h>
25 
26 #include <dst/dst.h>
27 
28 ISC_LANG_BEGINDECLS
29 
30 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
31 
32 static isc_mem_t *mctx = NULL;
33 
34 static void __attribute__((constructor)) init(void) {
35 	RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
36 	RUNTIME_CHECK(dst_lib_init(mctx, NULL) == ISC_R_SUCCESS);
37 }
38 
39 static void __attribute__((destructor)) deinit(void)
40 {
41 	dst_lib_destroy();
42 	isc_mem_destroy(&mctx);
43 }
44 
45 ISC_LANG_ENDDECLS
46