diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2014-05-20 22:36:27 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2014-05-20 22:36:27 (GMT) |
commit | 914f8a9a2ca86d82a7d65d086f316b89d1700859 (patch) | |
tree | 755ddfdf26ea23ac1998e8328bd9b307cd9ccc4b /programs | |
parent | 8c38ddd7e67354aa3205ac8c03e5b8f78f567a48 (diff) | |
download | lz4-914f8a9a2ca86d82a7d65d086f316b89d1700859.zip lz4-914f8a9a2ca86d82a7d65d086f316b89d1700859.tar.gz lz4-914f8a9a2ca86d82a7d65d086f316b89d1700859.tar.bz2 |
Added : fuzzer code for LZ4_compress_limitedOutput_usingDict()
Diffstat (limited to 'programs')
-rw-r--r-- | programs/fuzzer.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/programs/fuzzer.c b/programs/fuzzer.c index 081f0df..4b19703 100644 --- a/programs/fuzzer.c +++ b/programs/fuzzer.c @@ -204,6 +204,7 @@ int FUZ_test(U32 seed, int nbCycles, int startCycle, double compressibility) { void* stateLZ4 = malloc(LZ4_sizeofState()); void* stateLZ4HC = malloc(LZ4_sizeofStateHC()); void* LZ4continue; + LZ4_dict_t LZ4dict; U32 crcOrig, crcCheck; @@ -421,13 +422,22 @@ int FUZ_test(U32 seed, int nbCycles, int startCycle, double compressibility) { FUZ_DISPLAYTEST; dict -= 9; if (dict < (char*)CNBuffer) dict = (char*)CNBuffer; - { - LZ4_dict_t LZ4dict; - memset(&LZ4dict, 0, sizeof(LZ4_dict_t)); - LZ4_loadDict(&LZ4dict, dict, dictSize); - blockContinueCompressedSize = LZ4_compress_usingDict(&LZ4dict, block, compressedBuffer, blockSize); - FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_usingDict failed"); - } + memset(&LZ4dict, 0, sizeof(LZ4_dict_t)); + LZ4_loadDict(&LZ4dict, dict, dictSize); + blockContinueCompressedSize = LZ4_compress_usingDict(&LZ4dict, block, compressedBuffer, blockSize); + FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compress_usingDict failed"); + + FUZ_DISPLAYTEST; + memset(&LZ4dict, 0, sizeof(LZ4_dict_t)); + LZ4_loadDict(&LZ4dict, dict, dictSize); + ret = LZ4_compress_limitedOutput_usingDict(&LZ4dict, block, compressedBuffer, blockSize, blockContinueCompressedSize-1); + FUZ_CHECKTEST(ret>0, "LZ4_compress_limitedOutput_usingDict should fail : one missing byte for output buffer"); + + FUZ_DISPLAYTEST; + memset(&LZ4dict, 0, sizeof(LZ4_dict_t)); + LZ4_loadDict(&LZ4dict, dict, dictSize); + ret = LZ4_compress_limitedOutput_usingDict(&LZ4dict, block, compressedBuffer, blockSize, blockContinueCompressedSize); + FUZ_CHECKTEST(ret<=0, "LZ4_compress_limitedOutput_usingDict should work : enough size available within output buffer"); // Decompress with dictionary as external FUZ_DISPLAYTEST; |