1 /*
2  * Copyright (c) 2016-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under both the BSD-style license (found in the
6  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7  * in the COPYING file in the root directory of this source tree).
8  */
9 
10 /**
11  * Fuzz target interface.
12  * Fuzz targets have some common parameters passed as macros during compilation.
13  * Check the documentation for each individual fuzzer for more parameters.
14  *
15  * @param STATEFUL_FUZZING:
16  *        Define this to reuse state between fuzzer runs. This can be useful to
17  *        test code paths which are only executed when contexts are reused.
18  *        WARNING: Makes reproducing crashes much harder.
19  *        Default: Not defined.
20  * @param FUZZ_RNG_SEED_SIZE:
21  *        The number of bytes of the source to look at when constructing a seed
22  *        for the deterministic RNG. These bytes are discarded before passing
23  *        the data to zstd functions. Every fuzzer initializes the RNG exactly
24  *        once before doing anything else, even if it is unused.
25  *        Default: 4.
26  * @param DEBUGLEVEL:
27  *        This is a parameter for the zstd library. Defining `DEBUGLEVEL=1`
28  *        enables assert() statements in the zstd library. Higher levels enable
29  *        logging, so aren't recommended. Defining `DEBUGLEVEL=1` is
30  *        recommended.
31  * @param MEM_FORCE_MEMORY_ACCESS:
32  *        This flag controls how the zstd library accesses unaligned memory.
33  *        It can be undefined, or 0 through 2. If it is undefined, it selects
34  *        the method to use based on the compiler. If testing with UBSAN set
35  *        MEM_FORCE_MEMORY_ACCESS=0 to use the standard compliant method.
36  * @param FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
37  *        This is the canonical flag to enable deterministic builds for fuzzing.
38  *        Changes to zstd for fuzzing are gated behind this define.
39  *        It is recommended to define this when building zstd for fuzzing.
40  */
41 
42 #ifndef FUZZ_H
43 #define FUZZ_H
44 
45 #ifndef FUZZ_RNG_SEED_SIZE
46 #  define FUZZ_RNG_SEED_SIZE 4
47 #endif
48 
49 #include <stddef.h>
50 #include <stdint.h>
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size);
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif
63