]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use different fuzzer bits in example_dict_fuzzer for more input value combinations.
authorNathan Moinvaziri <nathan@solidstatenetworks.com>
Thu, 27 May 2021 16:31:47 +0000 (09:31 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 30 May 2021 13:49:39 +0000 (15:49 +0200)
test/fuzz/example_dict_fuzzer.c

index 027c9a806a0339493aefa6779f60789323c0c8b4..da1bb06c96ca7d7e37fa0f6918b65dbddea53f51 100644 (file)
@@ -42,13 +42,13 @@ void test_dict_deflate(unsigned char **compr, size_t *comprLen) {
 
     int method = Z_DEFLATED; /* The deflate compression method (the only one
                                 supported in this version) */
-    int windowBits = 8 + data[0] % 8; /* The windowBits parameter is the base
+    int windowBits = 8 + data[(dataLen > 1) ? 1:0] % 8; /* The windowBits parameter is the base
       two logarithm of the window size (the size of the history buffer).  It
       should be in the range 8..15 for this version of the library. */
-    int memLevel = 1 + data[0] % 9;   /* memLevel=1 uses minimum memory but is
+    int memLevel = 1 + data[(dataLen > 2) ? 2:0] % 9;   /* memLevel=1 uses minimum memory but is
       slow and reduces compression ratio; memLevel=9 uses maximum memory for
       optimal speed. */
-    int strategy = data[0] % 5;       /* [0..4]
+    int strategy = data[(dataLen > 3) ? 3:0] % 5;       /* [0..4]
       #define Z_FILTERED            1
       #define Z_HUFFMAN_ONLY        2
       #define Z_RLE                 3