diff options
author | Yann Collet <cyan@fb.com> | 2020-11-08 02:12:26 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2020-11-08 02:12:26 (GMT) |
commit | a2222a879fe77c33c96b5f9954a0328dc6df9850 (patch) | |
tree | 075c58c7e9e8fad99598c6b11f041b1698de2a6d /tests/fuzzer.c | |
parent | 1d02141bf8149c1f0091a4c2548cc4f28092f73a (diff) | |
download | lz4-a2222a879fe77c33c96b5f9954a0328dc6df9850.zip lz4-a2222a879fe77c33c96b5f9954a0328dc6df9850.tar.gz lz4-a2222a879fe77c33c96b5f9954a0328dc6df9850.tar.bz2 |
fix #926
fix incorrect behavior of LZ4_saveDictHC()
when invoked right after initialization.
Diffstat (limited to 'tests/fuzzer.c')
-rw-r--r-- | tests/fuzzer.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 29c6a8a..a411dd4 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -1135,13 +1135,13 @@ static void FUZ_unitTests(int compressionLevel) shct* const shc = (shct*)malloc(sizeof(*shc)); assert(shc != NULL); memset(shc, 0, sizeof(*shc)); - DISPLAYLEVEL(3, "state1(%p) state2(%p) state3(%p) size(0x%x): ", + DISPLAYLEVEL(3, "state1(%p) state2(%p) state3(%p) LZ4_stream_t size(0x%x): ", &(shc->state1), &(shc->state2), &(shc->state3), (unsigned)sizeof(LZ4_stream_t)); FUZ_CHECKTEST( LZ4_initStream(&(shc->state1), sizeof(shc->state1)) == NULL, "state1 (%p) failed init", &(shc->state1) ); FUZ_CHECKTEST( LZ4_initStream(&(shc->state2), sizeof(shc->state2)) == NULL, "state2 (%p) failed init", &(shc->state2) ); FUZ_CHECKTEST( LZ4_initStream(&(shc->state3), sizeof(shc->state3)) == NULL, "state3 (%p) failed init", &(shc->state3) ); FUZ_CHECKTEST( LZ4_initStream((char*)&(shc->state1) + 1, sizeof(shc->state1)) != NULL, - "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc->state1) + 1 ); + "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc->state1) + 1 ); free(shc); } DISPLAYLEVEL(3, "all inits OK \n"); @@ -1268,6 +1268,22 @@ static void FUZ_unitTests(int compressionLevel) } } DISPLAYLEVEL(3, "OK \n"); + /* saveDictHC test #926 */ + DISPLAYLEVEL(3, "saveDictHC test #926 : "); + { LZ4_streamHC_t* const ctx = LZ4_initStreamHC(&sHC, sizeof(sHC)); + assert(ctx != NULL); /* ensure init is successful */ + + /* Check access violation with asan */ + FUZ_CHECKTEST( LZ4_saveDictHC(&sHC, NULL, 0) != 0, + "LZ4_saveDictHC() can't save anything into (NULL,0)"); + + /* Check access violation with asan */ + { char tmp_buffer[240] = { 0 }; + FUZ_CHECKTEST( LZ4_saveDictHC(&sHC, tmp_buffer, sizeof(tmp_buffer)) != 0, + "LZ4_saveDictHC() can't save anything since compression hasn't started"); + } } + + /* long sequence test */ DISPLAYLEVEL(3, "Long sequence HC_destSize test : "); { size_t const blockSize = 1 MB; |