summaryrefslogtreecommitdiffstats
path: root/ossfuzz/round_trip_hc_fuzzer.c
diff options
context:
space:
mode:
Diffstat (limited to 'ossfuzz/round_trip_hc_fuzzer.c')
-rw-r--r--ossfuzz/round_trip_hc_fuzzer.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ossfuzz/round_trip_hc_fuzzer.c b/ossfuzz/round_trip_hc_fuzzer.c
index 325cdf0..22b5e8f 100644
--- a/ossfuzz/round_trip_hc_fuzzer.c
+++ b/ossfuzz/round_trip_hc_fuzzer.c
@@ -9,16 +9,21 @@
#include <string.h>
#include "fuzz_helpers.h"
+#include "fuzz_data_producer.h"
#include "lz4.h"
#include "lz4hc.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
- uint32_t seed = FUZZ_seed(&data, &size);
+ FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
size_t const dstCapacity = LZ4_compressBound(size);
char* const dst = (char*)malloc(dstCapacity);
char* const rt = (char*)malloc(size);
- int const level = FUZZ_rand32(&seed, LZ4HC_CLEVEL_MIN, LZ4HC_CLEVEL_MAX);
+ int const level = FUZZ_dataProducer_uint32(
+ producer, LZ4HC_CLEVEL_MIN, LZ4HC_CLEVEL_MAX);
+
+ /* Restrict to remaining data from producer */
+ size = producer->size;
FUZZ_ASSERT(dst);
FUZZ_ASSERT(rt);
@@ -34,6 +39,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
free(dst);
free(rt);
+ FUZZ_dataProducer_free(producer);
return 0;
}