diff options
author | Yann Collet <cyan@fb.com> | 2018-05-06 02:59:00 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2018-05-06 02:59:00 (GMT) |
commit | d7b6c726edb23fc19757dc84d4546863557bfe20 (patch) | |
tree | a7f822da35d03b30a6cacd8bdc6a042c0c1e7a8f /lib/lz4.c | |
parent | af127334670a5e7b710bbd6adb71aa7c3ef0cd72 (diff) | |
download | lz4-d7b6c726edb23fc19757dc84d4546863557bfe20.zip lz4-d7b6c726edb23fc19757dc84d4546863557bfe20.tar.gz lz4-d7b6c726edb23fc19757dc84d4546863557bfe20.tar.bz2 |
small extDict : fixed side-effect
don't fix dictionaries of size 0.
setting dictEnd == source triggers prefix mode,
thus removing possibility to use CDict.
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -683,13 +683,12 @@ LZ4_FORCE_INLINE int LZ4_compress_generic( /* Init conditions */ if (outputLimited == fillOutput && maxOutputSize < 1) return 0; /* Impossible to store anything */ if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported inputSize, too large (or negative) */ + if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ if (tableType==byPtr) assert(dictDirective==noDict); /* only supported use case with byPtr */ assert(acceleration >= 1); lowLimit = (const BYTE*)source - (dictDirective == withPrefix64k ? dictSize : 0); - if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ - /* Update context state */ if (dictDirective == usingDictCtx) { /* Subsequent linked blocks can't use the dictionary. */ @@ -1259,12 +1258,16 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, const char* source, ch LZ4_stream_t_internal* streamPtr = &LZ4_stream->internal_donotuse; const BYTE* dictEnd = streamPtr->dictionary + streamPtr->dictSize; + DEBUGLOG(5, "LZ4_compress_fast_continue (inputSize=%i)", inputSize); + if (streamPtr->initCheck) return 0; /* Uninitialized structure detected */ LZ4_renormDictT(streamPtr, inputSize); /* avoid index overflow */ if (acceleration < 1) acceleration = ACCELERATION_DEFAULT; /* invalidate tiny dictionaries */ - if (streamPtr->dictSize < 4) { + if ( (streamPtr->dictSize-1 < 4) /* intentional underflow */ + && (dictEnd != (const BYTE*)source) ) { + DEBUGLOG(5, "LZ4_compress_fast_continue: dictSize(%u) at addr:%p is too small", streamPtr->dictSize, streamPtr->dictionary); streamPtr->dictSize = 0; streamPtr->dictionary = (const BYTE*)source; dictEnd = (const BYTE*)source; |