diff options
author | Yann Collet <cyan@fb.com> | 2020-08-27 07:17:57 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-08-27 07:17:57 (GMT) |
commit | c5d6f8a8be3927c0bec91bcc58667a6cfad244ad (patch) | |
tree | 7ace9c0c38600b241a8775381941b9b634bd3f9d /tests/fuzzer.c | |
parent | 3e3a006c6f3337be4298e2c01ba3cb2c0ba04d45 (diff) | |
download | lz4-c5d6f8a8be3927c0bec91bcc58667a6cfad244ad.zip lz4-c5d6f8a8be3927c0bec91bcc58667a6cfad244ad.tar.gz lz4-c5d6f8a8be3927c0bec91bcc58667a6cfad244ad.tar.bz2 |
fix #783
LZ4_decompress_safe_partial()
now also supports a scenario where
nb_bytes_to_generate is <= block_decompressed_size
And
nb_bytes_to_read is >= block_compressed_size.
Previously, the only supported scenario was
nb_bytes_to_read == block_compress_size.
Pay attention that,
if nb_bytes_to_read is > block_compressed_size,
then, necessarily, it requires that
nb_bytes_to_generate is <= block_decompress_size.
If both are larger, it will generate corrupted data.
Diffstat (limited to 'tests/fuzzer.c')
-rw-r--r-- | tests/fuzzer.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/fuzzer.c b/tests/fuzzer.c index cbb53ca..beeb9d6 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -618,13 +618,13 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c /* Test partial decoding => must work */ FUZ_DISPLAYTEST("test LZ4_decompress_safe_partial"); - { size_t const missingBytes = FUZ_rand(&randState) % (unsigned)blockSize; - int const targetSize = (int)((size_t)blockSize - missingBytes); + { size_t const missingOutBytes = FUZ_rand(&randState) % (unsigned)blockSize; + int const targetSize = (int)((size_t)blockSize - missingOutBytes); size_t const extraneousInBytes = FUZ_rand(&randState) % 2; int const inCSize = (int)((size_t)compressedSize + extraneousInBytes); char const sentinel = decodedBuffer[targetSize] = block[targetSize] ^ 0x5A; - //DISPLAY("compressedSize=%i, inCSize=%i \n", compressedSize, inCSize); - //DISPLAY("decompressedSize=%i, targetDstSize=%i \n", blockSize, targetSize); + DISPLAYLEVEL(6,"compressedSize=%i, inCSize=%i \n", compressedSize, inCSize); + DISPLAYLEVEL(6,"decompressedSize=%i, targetDstSize=%i \n", blockSize, targetSize); int const decResult = LZ4_decompress_safe_partial(compressedBuffer, decodedBuffer, inCSize, targetSize, blockSize); FUZ_CHECKTEST(decResult<0, "LZ4_decompress_safe_partial failed despite valid input data (error:%i)", decResult); FUZ_CHECKTEST(decResult != targetSize, "LZ4_decompress_safe_partial did not regenerated required amount of data (%i < %i <= %i)", decResult, targetSize, blockSize); |