From: Yann Collet Date: Sun, 8 Nov 2020 02:24:02 +0000 (-0800) Subject: added similar tests for LZ4_saveDict() X-Git-Tag: upstream/1.9.3~1^2~13^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b16b9fcdbc110876c9cd82ac1c3392abc0c2e1b3;p=platform%2Fupstream%2Flz4.git added similar tests for LZ4_saveDict() fast (non-HC) variant --- diff --git a/tests/fuzzer.c b/tests/fuzzer.c index a411dd4..99361dd 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -1167,6 +1167,22 @@ static void FUZ_unitTests(int compressionLevel) FUZ_CHECKTEST(crcOrig!=crcNew, "LZ4_decompress_safe() decompression corruption"); } } + /* early saveDict */ + DISPLAYLEVEL(3, "saveDict (right after init) : "); + { LZ4_stream_t* const ctx = LZ4_initStream(&streamingState, sizeof(streamingState)); + assert(ctx != NULL); /* ensure init is successful */ + + /* Check access violation with asan */ + FUZ_CHECKTEST( LZ4_saveDict(&streamingState, NULL, 0) != 0, + "LZ4_saveDict() can't save anything into (NULL,0)"); + + /* Check access violation with asan */ + { char tmp_buffer[240] = { 0 }; + FUZ_CHECKTEST( LZ4_saveDict(&streamingState, tmp_buffer, sizeof(tmp_buffer)) != 0, + "LZ4_saveDict() can't save anything since compression hasn't started"); + } } + DISPLAYLEVEL(3, "OK \n"); + /* ring buffer test */ { XXH64_state_t xxhOrig; XXH64_state_t xxhNewSafe, xxhNewFast; @@ -1282,7 +1298,7 @@ static void FUZ_unitTests(int compressionLevel) FUZ_CHECKTEST( LZ4_saveDictHC(&sHC, tmp_buffer, sizeof(tmp_buffer)) != 0, "LZ4_saveDictHC() can't save anything since compression hasn't started"); } } - + DISPLAYLEVEL(3, "OK \n"); /* long sequence test */ DISPLAYLEVEL(3, "Long sequence HC_destSize test : ");