summaryrefslogtreecommitdiffstats
path: root/ossfuzz/round_trip_fuzzer.c
diff options
context:
space:
mode:
Diffstat (limited to 'ossfuzz/round_trip_fuzzer.c')
-rw-r--r--ossfuzz/round_trip_fuzzer.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ossfuzz/round_trip_fuzzer.c b/ossfuzz/round_trip_fuzzer.c
index e37a0a6..6307058 100644
--- a/ossfuzz/round_trip_fuzzer.c
+++ b/ossfuzz/round_trip_fuzzer.c
@@ -15,17 +15,18 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
- size_t const partialCapacity = FUZZ_dataProducer_uint32(producer, 0, size);
+ size_t const partialCapacitySeed = FUZZ_dataProducer_retrieve32(producer);
+ size = FUZZ_dataProducer_remainingBytes(producer);
+
+ size_t const partialCapacity = FUZZ_getRange_from_uint32(partialCapacitySeed, 0, size);
size_t const dstCapacity = LZ4_compressBound(size);
+
char* const dst = (char*)malloc(dstCapacity);
char* const rt = (char*)malloc(size);
FUZZ_ASSERT(dst);
FUZZ_ASSERT(rt);
- /* Restrict to remaining data from producer */
- size = FUZZ_dataProducer_remainingBytes(producer);
-
/* Compression must succeed and round trip correctly. */
int const dstSize = LZ4_compress_default((const char*)data, dst,
size, dstCapacity);