diff options
author | Yann Collet <cyan@fb.com> | 2020-09-26 18:31:57 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-09-26 18:31:57 (GMT) |
commit | ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace (patch) | |
tree | b1b330a8246b826f84dc48bdc4982fcdbe833d8e /tests | |
parent | 20856da7c571cc1ee55965a342527f8263dc356d (diff) | |
download | lz4-ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace.zip lz4-ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace.tar.gz lz4-ee4f37d2840c1faa41fb7110bbf6d1e58bf30ace.tar.bz2 |
fix compressing into NULL
fails properly
bug discovered by oss-fuzz
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fuzzer.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 1d8b5f6..4dbf6a7 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -1056,15 +1056,24 @@ static void FUZ_unitTests(int compressionLevel) } } - /* useful to trigger undefined sanitizer */ - DISPLAYLEVEL(3, "LZ4_compress_default() with NULL input \n"); + /* to be tested with undefined sanitizer */ + DISPLAYLEVEL(3, "LZ4_compress_default() with NULL input:"); { int const maxCSize = LZ4_compressBound(0); int const cSize = LZ4_compress_default(NULL, testCompressed, 0, maxCSize); FUZ_CHECKTEST(!(cSize==1 && testCompressed[0]==0), "compressing empty should give byte 0" - " (maxCSize == %u) (cSize == %u)", - (unsigned)maxCSize, (unsigned)cSize); + " (maxCSize == %i) (cSize == %i) (byte == 0x%02X)", + maxCSize, cSize, testCompressed[0]); } + DISPLAYLEVEL(3, " OK \n"); + + DISPLAYLEVEL(3, "LZ4_compress_default() with both NULL input and output:"); + { int const cSize = LZ4_compress_default(NULL, NULL, 0, 0); + FUZ_CHECKTEST(cSize != 0, + "compressing into NULL must fail" + " (cSize == %i != 0)", cSize); + } + DISPLAYLEVEL(3, " OK \n"); /* in-place compression test */ DISPLAYLEVEL(3, "in-place compression using LZ4_compress_default() :"); |