Rizin
unix-like reverse engineering framework and cli tools
|
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "fuzz_helpers.h"
#include "lz4.h"
#include "lz4hc.h"
Go to the source code of this file.
Classes | |
struct | const_cursor_t |
struct | cursor_t |
struct | state_t |
Macros | |
#define | LZ4_STATIC_LINKING_ONLY |
#define | LZ4_HC_STATIC_LINKING_ONLY |
Typedefs | |
typedef void(* | round_trip_t) (state_t *state) |
Functions | |
cursor_t | cursor_create (size_t size) |
void | cursor_free (cursor_t cursor) |
state_t | state_create (char const *data, size_t size, uint32_t seed) |
void | state_free (state_t state) |
static void | state_reset (state_t *state, uint32_t seed) |
static void | state_decompress (state_t *state, char const *src, int srcSize) |
static void | state_checkRoundTrip (state_t const *state) |
static size_t | state_trimDict (state_t *state) |
static void | state_prefixRoundTrip (state_t *state) |
static void | state_extDictRoundTrip (state_t *state) |
static void | state_randomRoundTrip (state_t *state, round_trip_t rt0, round_trip_t rt1) |
static void | state_loadDictRoundTrip (state_t *state) |
static void | state_attachDictRoundTrip (state_t *state) |
static void | state_prefixHCRoundTrip (state_t *state) |
static void | state_extDictHCRoundTrip (state_t *state) |
static void | state_loadDictHCRoundTrip (state_t *state) |
static void | state_attachDictHCRoundTrip (state_t *state) |
int | LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) |
Variables | |
round_trip_t | roundTrips [] |
#define LZ4_HC_STATIC_LINKING_ONLY |
Definition at line 15 of file round_trip_stream_fuzzer.c.
#define LZ4_STATIC_LINKING_ONLY |
This fuzz target performs a lz4 streaming round-trip test (compress & decompress), compares the result with the original, and calls abort() on corruption.
Definition at line 13 of file round_trip_stream_fuzzer.c.
Definition at line 51 of file round_trip_stream_fuzzer.c.
Definition at line 41 of file round_trip_stream_fuzzer.c.
References cursor_t::buf, FUZZ_ASSERT, malloc(), cursor_t::pos, and cursor_t::size.
Referenced by state_create(), state_extDictHCRoundTrip(), and state_extDictRoundTrip().
void cursor_free | ( | cursor_t | cursor | ) |
Definition at line 53 of file round_trip_stream_fuzzer.c.
References cursor_t::buf, and free().
Referenced by state_extDictHCRoundTrip(), state_extDictRoundTrip(), and state_free().
This fuzz target attempts to compress the fuzzed data with the simple compression function with an output buffer that may be too small to ensure that the compressor never crashes.
This fuzz target attempts to decompress the fuzzed data with the simple decompression function to ensure the decompressor never crashes.
This fuzz target performs a lz4 round-trip test (compress & decompress), compares the result with the original, and calls abort() on corruption.
Definition at line 285 of file round_trip_stream_fuzzer.c.
References arch, assert(), count, cs_close(), cs_disasm(), cs_disasm_iter(), cs_free(), cs_group_name(), cs_insn_name(), cs_malloc(), cs_open(), CS_OPT_DETAIL, CS_OPT_ON, cs_option(), cs_reg_name(), DEBUGLOG, test_evm::detail, err, FUZZ_seed(), handle, i, int, LLVMFuzzerInit(), LLVMFuzzerReturnOneInput(), n, NULL, outfile, platforms, printf(), PRIx64, roundTrips, snprintf, state_checkRoundTrip(), state_create(), state_free(), and state_reset().
Referenced by main().
|
static |
Definition at line 260 of file round_trip_stream_fuzzer.c.
References LZ4_attach_HC_dictionary(), LZ4_createStreamHC(), LZ4_freeStreamHC(), LZ4_loadDictHC(), LZ4_setCompressionLevel(), LZ4_setStreamDecode(), state_extDictHCRoundTrip(), state_prefixHCRoundTrip(), state_randomRoundTrip(), and state_trimDict().
|
static |
Definition at line 197 of file round_trip_stream_fuzzer.c.
References LZ4_attach_dictionary(), LZ4_createStream(), LZ4_freeStream(), LZ4_loadDict(), LZ4_setStreamDecode(), state_extDictRoundTrip(), state_prefixRoundTrip(), state_randomRoundTrip(), and state_trimDict().
Definition at line 113 of file round_trip_stream_fuzzer.c.
References FUZZ_ASSERT_MSG.
Referenced by LLVMFuzzerTestOneInput().
Definition at line 58 of file round_trip_stream_fuzzer.c.
References cursor_create(), FUZZ_ASSERT, LZ4_compressBound(), LZ4_createStream(), LZ4_createStreamDecode(), and LZ4_createStreamHC().
Referenced by LLVMFuzzerTestOneInput().
Definition at line 103 of file round_trip_stream_fuzzer.c.
References dst, FUZZ_ASSERT, LZ4_decompress_safe_continue(), src, and srcSize.
Referenced by state_extDictHCRoundTrip(), state_extDictRoundTrip(), state_prefixHCRoundTrip(), and state_prefixRoundTrip().
|
static |
Definition at line 226 of file round_trip_stream_fuzzer.c.
References cursor_t::buf, cursor_create(), cursor_free(), DEBUGLOG, dst, FUZZ_ASSERT, FUZZ_rand32(), i, LZ4_compress_HC_continue(), memcpy(), src, srcSize, and state_decompress().
Referenced by state_attachDictHCRoundTrip(), and state_loadDictHCRoundTrip().
|
static |
Definition at line 156 of file round_trip_stream_fuzzer.c.
References cursor_t::buf, cursor_create(), cursor_free(), dst, FUZZ_ASSERT, FUZZ_rand32(), i, LZ4_compress_fast_continue(), memcpy(), src, srcSize, and state_decompress().
Referenced by state_attachDictRoundTrip(), and state_loadDictRoundTrip().
void state_free | ( | state_t | state | ) |
Definition at line 82 of file round_trip_stream_fuzzer.c.
References cursor_free(), LZ4_freeStream(), LZ4_freeStreamDecode(), and LZ4_freeStreamHC().
Referenced by LLVMFuzzerTestOneInput().
|
static |
Definition at line 250 of file round_trip_stream_fuzzer.c.
References LZ4_loadDictHC(), LZ4_setStreamDecode(), state_extDictHCRoundTrip(), state_prefixHCRoundTrip(), state_randomRoundTrip(), and state_trimDict().
|
static |
Definition at line 188 of file round_trip_stream_fuzzer.c.
References LZ4_loadDict(), LZ4_setStreamDecode(), state_extDictRoundTrip(), state_prefixRoundTrip(), state_randomRoundTrip(), and state_trimDict().
|
static |
Definition at line 209 of file round_trip_stream_fuzzer.c.
References dst, FUZZ_ASSERT, FUZZ_rand32(), LZ4_compress_HC_continue(), src, srcSize, and state_decompress().
Referenced by state_attachDictHCRoundTrip(), and state_loadDictHCRoundTrip().
|
static |
Definition at line 139 of file round_trip_stream_fuzzer.c.
References dst, FUZZ_ASSERT, FUZZ_rand32(), LZ4_compress_fast_continue(), src, srcSize, and state_decompress().
Referenced by state_attachDictRoundTrip(), and state_loadDictRoundTrip().
|
static |
Definition at line 178 of file round_trip_stream_fuzzer.c.
References FUZZ_rand32().
Referenced by state_attachDictHCRoundTrip(), state_attachDictRoundTrip(), state_loadDictHCRoundTrip(), and state_loadDictRoundTrip().
Definition at line 91 of file round_trip_stream_fuzzer.c.
References FUZZ_rand32(), LZ4_resetStream_fast(), LZ4_resetStreamHC_fast(), LZ4_setStreamDecode(), LZ4HC_CLEVEL_MAX, LZ4HC_CLEVEL_MIN, and NULL.
Referenced by LLVMFuzzerTestOneInput().
Picks a dictionary size and trims the dictionary off of the data. We copy the dictionary to the roundTrip so our validation passes.
Definition at line 125 of file round_trip_stream_fuzzer.c.
References DEBUGLOG, FUZZ_ASSERT, FUZZ_rand32(), memcpy(), and MIN.
Referenced by state_attachDictHCRoundTrip(), state_attachDictRoundTrip(), state_loadDictHCRoundTrip(), and state_loadDictRoundTrip().
round_trip_t roundTrips[] |
Definition at line 274 of file round_trip_stream_fuzzer.c.
Referenced by LLVMFuzzerTestOneInput().