summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-12-04 22:05:11 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-12-04 22:05:11 (GMT)
commit535636ff5cca702e4b5eb8e602c0ce70bfcde2c1 (patch)
tree4e9b7978b465df062589f1e1f4167dd9663411d4 /lib
parent3a510831c31500e94f9fd732b586ef7b92642d2c (diff)
downloadlz4-535636ff5cca702e4b5eb8e602c0ce70bfcde2c1.zip
lz4-535636ff5cca702e4b5eb8e602c0ce70bfcde2c1.tar.gz
lz4-535636ff5cca702e4b5eb8e602c0ce70bfcde2c1.tar.bz2
Don't Attach Very Small Dictionaries
Fixes a mismatch in behavior between loading into the context (via `LZ4_loadDict()`) a very small (<= 4 bytes) non-contiguous dictionary, versus attaching it with `LZ4_attach_dictionary()`. Before this patch, this divergence could be reproduced by running ``` make -C tests fuzzer MOREFLAGS="-m32" tests/fuzzer -v -s1239 -t3146 ``` Making sure these two paths behave exactly identically is an easy way to test the correctness of the attach path, so it's desirable that this remain an unpolluted, high signal test.
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index dd9edcc..87cbb99 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1271,7 +1271,9 @@ void LZ4_attach_dictionary(LZ4_stream_t *working_stream, const LZ4_stream_t *dic
*/
LZ4_resetStream_fast(working_stream);
- if (dictionary_stream != NULL) {
+ if (dictionary_stream != NULL
+ && dictionary_stream->internal_donotuse.dictSize - 1 >= 4
+ /* intentional underflow */) {
/* If the current offset is zero, we will never look in the
* external dictionary context, since there is no value a table
* entry can take that indicate a miss. In that case, we need