summaryrefslogtreecommitdiffstats
path: root/ossfuzz/compress_fuzzer.c
diff options
context:
space:
mode:
authorbimbashrestha <bshrestha.msae@gmail.com>2019-08-16 23:43:28 (GMT)
committerbimbashrestha <bshrestha.msae@gmail.com>2019-08-16 23:43:28 (GMT)
commitf839e9fe8a393117c64dff58196d36b741780ab0 (patch)
tree8e631d375b6b734bd2e8f8385b5e289862a4f3b3 /ossfuzz/compress_fuzzer.c
parenta9ac05645644a0615b558f6ac655c4ae46c4a926 (diff)
downloadlz4-f839e9fe8a393117c64dff58196d36b741780ab0.zip
lz4-f839e9fe8a393117c64dff58196d36b741780ab0.tar.gz
lz4-f839e9fe8a393117c64dff58196d36b741780ab0.tar.bz2
Seperating fuzz data producer api impl and header, using data producer on the easy fuzzers
Diffstat (limited to 'ossfuzz/compress_fuzzer.c')
-rw-r--r--ossfuzz/compress_fuzzer.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ossfuzz/compress_fuzzer.c b/ossfuzz/compress_fuzzer.c
index 7021624..42efbd3 100644
--- a/ossfuzz/compress_fuzzer.c
+++ b/ossfuzz/compress_fuzzer.c
@@ -10,15 +10,20 @@
#include <string.h>
#include "fuzz_helpers.h"
+#include "fuzz_data_producer.h"
#include "lz4.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
- uint32_t seed = FUZZ_seed(&data, &size);
- size_t const dstCapacity = FUZZ_rand32(&seed, 0, LZ4_compressBound(size));
+ FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
+ size_t const dstCapacity = FUZZ_dataProducer_uint32(
+ producer, 0, LZ4_compressBound(size));
char* const dst = (char*)malloc(dstCapacity);
char* const rt = (char*)malloc(size);
+ /* Restrict to remaining data from producer */
+ size = producer->size;
+
FUZZ_ASSERT(dst);
FUZZ_ASSERT(rt);
@@ -46,6 +51,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
free(dst);
free(rt);
+ FUZZ_dataProducer_free(producer);
return 0;
}