fuzz.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Fuzz target interface.
  3. * Fuzz targets have some common parameters passed as macros during compilation.
  4. * Check the documentation for each individual fuzzer for more parameters.
  5. *
  6. * @param FUZZ_RNG_SEED_SIZE:
  7. * The number of bytes of the source to look at when constructing a seed
  8. * for the deterministic RNG. These bytes are discarded before passing
  9. * the data to lz4 functions. Every fuzzer initializes the RNG exactly
  10. * once before doing anything else, even if it is unused.
  11. * Default: 4.
  12. * @param LZ4_DEBUG:
  13. * This is a parameter for the lz4 library. Defining `LZ4_DEBUG=1`
  14. * enables assert() statements in the lz4 library. Higher levels enable
  15. * logging, so aren't recommended. Defining `LZ4_DEBUG=1` is
  16. * recommended.
  17. * @param LZ4_FORCE_MEMORY_ACCESS:
  18. * This flag controls how the zstd library accesses unaligned memory.
  19. * It can be undefined, or 0 through 2. If it is undefined, it selects
  20. * the method to use based on the compiler. If testing with UBSAN set
  21. * MEM_FORCE_MEMORY_ACCESS=0 to use the standard compliant method.
  22. * @param FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  23. * This is the canonical flag to enable deterministic builds for fuzzing.
  24. * Changes to zstd for fuzzing are gated behind this define.
  25. * It is recommended to define this when building zstd for fuzzing.
  26. */
  27. #ifndef FUZZ_H
  28. #define FUZZ_H
  29. #ifndef FUZZ_RNG_SEED_SIZE
  30. # define FUZZ_RNG_SEED_SIZE 4
  31. #endif
  32. #include <stddef.h>
  33. #include <stdint.h>
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif