aboutsummaryrefslogtreecommitdiff
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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ossfuzz/round_trip_hc_fuzzer.c b/ossfuzz/round_trip_hc_fuzzer.c
index 325cdf0e..7d03ee2d 100644
--- a/ossfuzz/round_trip_hc_fuzzer.c
+++ b/ossfuzz/round_trip_hc_fuzzer.c
@@ -9,16 +9,20 @@
#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);
+ int const level = FUZZ_dataProducer_range32(producer,
+ LZ4HC_CLEVEL_MIN, LZ4HC_CLEVEL_MAX);
+ size = FUZZ_dataProducer_remainingBytes(producer);
+
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);
FUZZ_ASSERT(dst);
FUZZ_ASSERT(rt);
@@ -34,6 +38,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
free(dst);
free(rt);
+ FUZZ_dataProducer_free(producer);
return 0;
}