xref: /freebsd/contrib/libder/tests/fuzzers.h (revision 35c0a8c449fd2b7f75029ebed5e10852240f0865)
1*35c0a8c4SKyle Evans /*-
2*35c0a8c4SKyle Evans  * Copyright (c) 2024 Kyle Evans <kevans@FreeBSD.org>
3*35c0a8c4SKyle Evans  *
4*35c0a8c4SKyle Evans  * SPDX-License-Identifier: BSD-2-Clause
5*35c0a8c4SKyle Evans  */
6*35c0a8c4SKyle Evans 
7*35c0a8c4SKyle Evans #pragma once
8*35c0a8c4SKyle Evans 
9*35c0a8c4SKyle Evans #include <stdint.h>
10*35c0a8c4SKyle Evans 
11*35c0a8c4SKyle Evans enum stream_type {
12*35c0a8c4SKyle Evans 	STREAM_FD = 0,		/* read_fd() type */
13*35c0a8c4SKyle Evans 	STREAM_FILE = 1,	/* read_file() type */
14*35c0a8c4SKyle Evans 	STREAM_PLAIN = 2,
15*35c0a8c4SKyle Evans 
16*35c0a8c4SKyle Evans 	STREAM_END
17*35c0a8c4SKyle Evans } __attribute__((packed));
18*35c0a8c4SKyle Evans 
19*35c0a8c4SKyle Evans enum stream_buffer {
20*35c0a8c4SKyle Evans 	BUFFER_NONE = 0,
21*35c0a8c4SKyle Evans 	BUFFER_FULL = 1,
22*35c0a8c4SKyle Evans 
23*35c0a8c4SKyle Evans 	BUFFER_END,
24*35c0a8c4SKyle Evans } __attribute__((packed));
25*35c0a8c4SKyle Evans 
26*35c0a8c4SKyle Evans struct fuzz_params {
27*35c0a8c4SKyle Evans 	enum stream_type	 type;
28*35c0a8c4SKyle Evans 	enum stream_buffer	 buftype;
29*35c0a8c4SKyle Evans 
30*35c0a8c4SKyle Evans #define	PARAM_PAD_START	_pad0
31*35c0a8c4SKyle Evans 	uint8_t			 strict;
32*35c0a8c4SKyle Evans 	uint8_t			 _pad0[5];
33*35c0a8c4SKyle Evans 
34*35c0a8c4SKyle Evans 	/* Give me plenty of padding. */
35*35c0a8c4SKyle Evans 	uint64_t		 padding[3];
36*35c0a8c4SKyle Evans };
37*35c0a8c4SKyle Evans 
38*35c0a8c4SKyle Evans _Static_assert(sizeof(struct fuzz_params) == 32,
39*35c0a8c4SKyle Evans     "fuzz_params ABI broken, will invalidate CORPUS");
40*35c0a8c4SKyle Evans 
41