From 22ec5c7469da5a39d3178e79b20df5f3eb450d7c Mon Sep 17 00:00:00 2001 From: Greg Tucker Date: Tue, 21 Nov 2017 13:26:49 -0700 Subject: [PATCH] igzip: Fix igzip fuzz test for lev2-3 buf size Also remove unnecessary deps in igzip makefile. Change-Id: I1ff79461df6d60bfc52c99b574c39098f1fe238a Signed-off-by: Greg Tucker --- igzip/Makefile.am | 3 -- .../fuzz/igzip_simple_round_trip_fuzz_test.c | 28 +++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/igzip/Makefile.am b/igzip/Makefile.am index d917251..fc6bb5a 100644 --- a/igzip/Makefile.am +++ b/igzip/Makefile.am @@ -123,6 +123,3 @@ igzip_inflate_test: LDLIBS += -lz igzip_igzip_inflate_test_LDADD = libisal.la igzip_igzip_inflate_test_LDFLAGS = -lz igzip_igzip_hist_perf_LDADD = libisal.la -igzip_fuzz_inflate: LDLIBS += -lz -igzip_igzip_fuzz_inflate_LDADD = libisal.la -igzip_igzip_fuzz_inflate_LDFLAGS = -lz diff --git a/tests/fuzz/igzip_simple_round_trip_fuzz_test.c b/tests/fuzz/igzip_simple_round_trip_fuzz_test.c index 106fc3c..1190e0c 100644 --- a/tests/fuzz/igzip_simple_round_trip_fuzz_test.c +++ b/tests/fuzz/igzip_simple_round_trip_fuzz_test.c @@ -55,12 +55,28 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) wrapper_type = (in_param & HEADER_BIT_MASK) % (IGZIP_ZLIB_NO_HDR + 1); in_param >>= HEADER_BITS; - lev_buf_size = (0 == level) ? - ISAL_DEF_LVL0_MIN + (in_param) * (ISAL_DEF_LVL0_EXTRA_LARGE / - LEVEL_BIT_MASK) : - ISAL_DEF_LVL1_MIN + (in_param) * (ISAL_DEF_LVL1_EXTRA_LARGE / - LEVEL_BIT_MASK); - + switch (level) { + case 0: + lev_buf_size = ISAL_DEF_LVL0_MIN + (in_param) * + (ISAL_DEF_LVL0_EXTRA_LARGE / LEVEL_BIT_MASK); + break; + case 1: + lev_buf_size = ISAL_DEF_LVL1_MIN + (in_param) * + (ISAL_DEF_LVL1_EXTRA_LARGE / LEVEL_BIT_MASK); + break; +#ifdef ISAL_DEF_LVL2_MIN + case 2: + lev_buf_size = ISAL_DEF_LVL2_MIN + (in_param) * + (ISAL_DEF_LVL2_EXTRA_LARGE / LEVEL_BIT_MASK); + break; +#endif +#ifdef ISAL_DEF_LVL3_MIN + case 3: + lev_buf_size = ISAL_DEF_LVL3_MIN + (in_param) * + (ISAL_DEF_LVL3_EXTRA_LARGE / LEVEL_BIT_MASK); + break; +#endif + } if (0 == level) cmp_buf_size = 2 * size + ISAL_DEF_MAX_HDR_SIZE; else