Yann Collet | e21384f | 2017-08-31 12:11:57 -0700 | [diff] [blame] | 1 | /* |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 3 | * All rights reserved. |
| 4 | * |
Yann Collet | e21384f | 2017-08-31 12:11:57 -0700 | [diff] [blame] | 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). |
Nick Terrell | ac58c8d | 2020-03-26 15:19:05 -0700 | [diff] [blame] | 8 | * You may select, at your option, one of the above-listed licenses. |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * Fuzz target interface. |
| 13 | * Fuzz targets have some common parameters passed as macros during compilation. |
| 14 | * Check the documentation for each individual fuzzer for more parameters. |
| 15 | * |
Nick Terrell | 677c2cb | 2017-09-12 20:20:27 -0700 | [diff] [blame] | 16 | * @param STATEFUL_FUZZING: |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 17 | * Define this to reuse state between fuzzer runs. This can be useful to |
| 18 | * test code paths which are only executed when contexts are reused. |
| 19 | * WARNING: Makes reproducing crashes much harder. |
| 20 | * Default: Not defined. |
Yann Collet | fa41bcc | 2018-06-13 14:59:26 -0400 | [diff] [blame] | 21 | * @param DEBUGLEVEL: |
| 22 | * This is a parameter for the zstd library. Defining `DEBUGLEVEL=1` |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 23 | * enables assert() statements in the zstd library. Higher levels enable |
Yann Collet | fa41bcc | 2018-06-13 14:59:26 -0400 | [diff] [blame] | 24 | * logging, so aren't recommended. Defining `DEBUGLEVEL=1` is |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 25 | * recommended. |
| 26 | * @param MEM_FORCE_MEMORY_ACCESS: |
| 27 | * This flag controls how the zstd library accesses unaligned memory. |
| 28 | * It can be undefined, or 0 through 2. If it is undefined, it selects |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 29 | * the method to use based on the compiler. |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 30 | * @param FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
| 31 | * This is the canonical flag to enable deterministic builds for fuzzing. |
| 32 | * Changes to zstd for fuzzing are gated behind this define. |
| 33 | * It is recommended to define this when building zstd for fuzzing. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 34 | * @param FUZZ_THIRD_PARTY_SEQ_PROD |
| 35 | * This flag allows sequence producer plugin authors to replace the built-in |
| 36 | * default sequence producer with their own code. If you are not a plugin |
| 37 | * author, you should not define this flag. See the docs at |
| 38 | * fuzz_third_party_seq_prod.h for more information. |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 39 | */ |
| 40 | |
| 41 | #ifndef FUZZ_H |
| 42 | #define FUZZ_H |
| 43 | |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 44 | #include <stddef.h> |
| 45 | #include <stdint.h> |
| 46 | |
Nick Terrell | 677c2cb | 2017-09-12 20:20:27 -0700 | [diff] [blame] | 47 | #ifdef __cplusplus |
| 48 | extern "C" { |
| 49 | #endif |
| 50 | |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 51 | int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size); |
| 52 | |
Nick Terrell | 677c2cb | 2017-09-12 20:20:27 -0700 | [diff] [blame] | 53 | #ifdef __cplusplus |
| 54 | } |
| 55 | #endif |
| 56 | |
Nick Terrell | 4be7f0d | 2017-06-29 16:53:52 -0700 | [diff] [blame] | 57 | #endif |