diff options
author | Bimba Shrestha <bshrestha.msae@gmail.com> | 2019-09-13 23:04:48 (GMT) |
---|---|---|
committer | Bimba Shrestha <bshrestha.msae@gmail.com> | 2019-09-13 23:04:48 (GMT) |
commit | 9cb73d69c4d92e255826dfee47e46a6815955ee4 (patch) | |
tree | 8d0a64a8555b52035e52350a45858dc2bd910165 /ossfuzz/fuzz_data_producer.c | |
parent | 208694297a308da8dae2b3bb104bdab486d1b683 (diff) | |
download | lz4-9cb73d69c4d92e255826dfee47e46a6815955ee4.zip lz4-9cb73d69c4d92e255826dfee47e46a6815955ee4.tar.gz lz4-9cb73d69c4d92e255826dfee47e46a6815955ee4.tar.bz2 |
Addressing naming nits and moving size modification up in all fuzzers
Diffstat (limited to 'ossfuzz/fuzz_data_producer.c')
-rw-r--r-- | ossfuzz/fuzz_data_producer.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ossfuzz/fuzz_data_producer.c b/ossfuzz/fuzz_data_producer.c index 70e42ea..9557f58 100644 --- a/ossfuzz/fuzz_data_producer.c +++ b/ossfuzz/fuzz_data_producer.c @@ -17,7 +17,7 @@ FUZZ_dataProducer_t *FUZZ_dataProducer_create(const uint8_t *data, size_t size) void FUZZ_dataProducer_free(FUZZ_dataProducer_t *producer) { free(producer); } -uint32_t FUZZ_dataProducer_uint32_seed(FUZZ_dataProducer_t *producer, uint32_t min, +uint32_t FUZZ_dataProducer_uint32(FUZZ_dataProducer_t *producer, uint32_t min, uint32_t max) { FUZZ_ASSERT(min <= max); @@ -35,7 +35,7 @@ uint32_t FUZZ_dataProducer_uint32_seed(FUZZ_dataProducer_t *producer, uint32_t m return result; } -uint32_t FUZZ_dataProducer_uint32(uint32_t seed, uint32_t min, uint32_t max) +uint32_t FUZZ_getRange_from_uint32(uint32_t seed, uint32_t min, uint32_t max) { uint32_t range = max - min; if (range == 0xffffffff) { @@ -44,24 +44,24 @@ uint32_t FUZZ_dataProducer_uint32(uint32_t seed, uint32_t min, uint32_t max) return min + seed % (range + 1); } -uint32_t FUZZ_dataProducer_uint32NonAdaptive(FUZZ_dataProducer_t* producer, +uint32_t FUZZ_dataProducer_range32(FUZZ_dataProducer_t* producer, uint32_t min, uint32_t max) { - size_t const seed = FUZZ_dataProducer_uint32_seed(producer, min, max); - return FUZZ_dataProducer_uint32(seed, min, max); + size_t const seed = FUZZ_dataProducer_uint32(producer, min, max); + return FUZZ_getRange_from_uint32(seed, min, max); } LZ4F_frameInfo_t FUZZ_dataProducer_frameInfo(FUZZ_dataProducer_t* producer) { LZ4F_frameInfo_t info = LZ4F_INIT_FRAMEINFO; - info.blockSizeID = FUZZ_dataProducer_uint32NonAdaptive(producer, LZ4F_max64KB - 1, LZ4F_max4MB); + info.blockSizeID = FUZZ_dataProducer_range32(producer, LZ4F_max64KB - 1, LZ4F_max4MB); if (info.blockSizeID < LZ4F_max64KB) { info.blockSizeID = LZ4F_default; } - info.blockMode = FUZZ_dataProducer_uint32NonAdaptive(producer, LZ4F_blockLinked, LZ4F_blockIndependent); - info.contentChecksumFlag = FUZZ_dataProducer_uint32NonAdaptive(producer, LZ4F_noContentChecksum, + info.blockMode = FUZZ_dataProducer_range32(producer, LZ4F_blockLinked, LZ4F_blockIndependent); + info.contentChecksumFlag = FUZZ_dataProducer_range32(producer, LZ4F_noContentChecksum, LZ4F_contentChecksumEnabled); - info.blockChecksumFlag = FUZZ_dataProducer_uint32NonAdaptive(producer, LZ4F_noBlockChecksum, + info.blockChecksumFlag = FUZZ_dataProducer_range32(producer, LZ4F_noBlockChecksum, LZ4F_blockChecksumEnabled); return info; } @@ -70,9 +70,9 @@ 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_uint32NonAdaptive(producer, 0, LZ4HC_CLEVEL_MAX + 3) - 3; - prefs.autoFlush = FUZZ_dataProducer_uint32NonAdaptive(producer, 0, 1); - prefs.favorDecSpeed = FUZZ_dataProducer_uint32NonAdaptive(producer, 0, 1); + prefs.compressionLevel = FUZZ_dataProducer_range32(producer, 0, LZ4HC_CLEVEL_MAX + 3) - 3; + prefs.autoFlush = FUZZ_dataProducer_range32(producer, 0, 1); + prefs.favorDecSpeed = FUZZ_dataProducer_range32(producer, 0, 1); return prefs; } |