summaryrefslogtreecommitdiffstats
path: root/ossfuzz/fuzz_data_producer.c
diff options
context:
space:
mode:
authorBimba Shrestha <bshrestha.msae@gmail.com>2019-08-30 17:27:42 (GMT)
committerBimba Shrestha <bshrestha.msae@gmail.com>2019-08-30 17:27:42 (GMT)
commit7d153a704d00a266c9601c947e07fd33e1cd6f4d (patch)
treeab51d65880c31a8040251f378d1ef25ba6dd721e /ossfuzz/fuzz_data_producer.c
parentdc17d39c2fb962b591c73cf1467d89cf53b89156 (diff)
downloadlz4-7d153a704d00a266c9601c947e07fd33e1cd6f4d.zip
lz4-7d153a704d00a266c9601c947e07fd33e1cd6f4d.tar.gz
lz4-7d153a704d00a266c9601c947e07fd33e1cd6f4d.tar.bz2
Making fuzzers use dataProducer api instead of random seed for decisions
Diffstat (limited to 'ossfuzz/fuzz_data_producer.c')
-rw-r--r--ossfuzz/fuzz_data_producer.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ossfuzz/fuzz_data_producer.c b/ossfuzz/fuzz_data_producer.c
index 992f5a7..f35bd8a 100644
--- a/ossfuzz/fuzz_data_producer.c
+++ b/ossfuzz/fuzz_data_producer.c
@@ -39,6 +39,31 @@ uint32_t FUZZ_dataProducer_uint32(FUZZ_dataProducer_t *producer, uint32_t min,
return min + result % (range + 1);
}
+LZ4F_frameInfo_t FUZZ_dataProducer_frameInfo(FUZZ_dataProducer_t* producer)
+{
+ LZ4F_frameInfo_t info = LZ4F_INIT_FRAMEINFO;
+ info.blockSizeID = FUZZ_dataProducer_uint32(producer, LZ4F_max64KB - 1, LZ4F_max4MB);
+ if (info.blockSizeID < LZ4F_max64KB) {
+ info.blockSizeID = LZ4F_default;
+ }
+ info.blockMode = FUZZ_dataProducer_uint32(producer, LZ4F_blockLinked, LZ4F_blockIndependent);
+ info.contentChecksumFlag = FUZZ_dataProducer_uint32(producer, LZ4F_noContentChecksum,
+ LZ4F_contentChecksumEnabled);
+ info.blockChecksumFlag = FUZZ_dataProducer_uint32(producer, LZ4F_noBlockChecksum,
+ LZ4F_blockChecksumEnabled);
+ return info;
+}
+
+LZ4F_preferences_t FUZZ_dataProducer_preferences(FUZZ_dataProducer_t* producer)
+{
+ LZ4F_preferences_t prefs = LZ4F_INIT_PREFERENCES;
+ prefs.frameInfo = FUZZ_dataProducer_frameInfo(producer);
+ prefs.compressionLevel = FUZZ_dataProducer_uint32(producer, 0, LZ4HC_CLEVEL_MAX + 3) - 3;
+ prefs.autoFlush = FUZZ_dataProducer_uint32(producer, 0, 1);
+ prefs.favorDecSpeed = FUZZ_dataProducer_uint32(producer, 0, 1);
+ return prefs;
+}
+
size_t FUZZ_dataProducer_remainingBytes(FUZZ_dataProducer_t *producer){
return producer->size;
}