summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-05-02 18:10:28 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-05-02 18:10:28 (GMT)
commit791512cfddac1dd789ebfdbf1880553a17b57ccb (patch)
tree89326cc583faf8a23dad9940c51b968f1b2ebba7
parent2a974d73c35476eb66275dd0d9448a6efa51bf56 (diff)
downloadlz4-791512cfddac1dd789ebfdbf1880553a17b57ccb.zip
lz4-791512cfddac1dd789ebfdbf1880553a17b57ccb.tar.gz
lz4-791512cfddac1dd789ebfdbf1880553a17b57ccb.tar.bz2
Fixed bug 9318
-rw-r--r--lib/lz4.c10
-rw-r--r--programs/fuzzer.c2
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 538aad4..6fed55a 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -767,7 +767,8 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
const BYTE* const dictEnd = p + dictSize;
const BYTE* base;
- if (dict->initCheck) LZ4_resetStream(LZ4_dict); /* Uninitialized structure detected */
+ if (dict->initCheck) /* Uninitialized structure detected */
+ LZ4_resetStream(LZ4_dict);
if (dictSize < (int)HASH_UNIT)
{
@@ -776,7 +777,8 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
return 0;
}
- if (p <= dictEnd - 64 KB) p = dictEnd - 64 KB;
+ if ((dictEnd - p) > 64 KB) p = dictEnd - 64 KB;
+ dict->currentOffset += 64 KB;
base = p - dict->currentOffset;
dict->dictionary = p;
dict->dictSize = (U32)(dictEnd - p);
@@ -784,7 +786,7 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize)
while (p <= dictEnd-HASH_UNIT)
{
- LZ4_putPosition(p, dict, byU32, base);
+ LZ4_putPosition(p, dict->hashTable, byU32, base);
p+=3;
}
@@ -1260,7 +1262,7 @@ int LZ4_compress_limitedOutput(const char* source, char* dest, int inputSize, in
int LZ4_compress(const char* source, char* dest, int inputSize) { return LZ4_compress_safe(source, dest, inputSize, LZ4_compressBound(inputSize)); }
int LZ4_compress_limitedOutput_withState (void* state, const char* src, char* dst, int srcSize, int dstSize) { return LZ4_compress_safe_extState(state, src, dst, srcSize, dstSize); }
int LZ4_compress_withState (void* state, const char* src, char* dst, int srcSize) { return LZ4_compress_safe_extState(state, src, dst, srcSize, LZ4_compressBound(srcSize)); }
-int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize, int maxOutputSize) { return LZ4_compress_safe_continue(LZ4_stream, source, dest, inputSize, maxOutputSize); }
+int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_stream, const char* src, char* dst, int srcSize, int maxDstSize) { return LZ4_compress_safe_continue(LZ4_stream, src, dst, srcSize, maxDstSize); }
int LZ4_compress_continue (LZ4_stream_t* LZ4_stream, const char* source, char* dest, int inputSize) { return LZ4_compress_safe_continue(LZ4_stream, source, dest, inputSize, LZ4_compressBound(inputSize)); }
/*
diff --git a/programs/fuzzer.c b/programs/fuzzer.c
index 2bf3cfe..9fd4648 100644
--- a/programs/fuzzer.c
+++ b/programs/fuzzer.c
@@ -596,7 +596,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
FUZ_DISPLAYTEST;
LZ4_loadDict(&LZ4dict, dict, dictSize);
ret = LZ4_compress_limitedOutput_continue(&LZ4dict, block, compressedBuffer, blockSize, blockContinueCompressedSize-1);
- FUZ_CHECKTEST(ret>0, "LZ4_compress_limitedOutput_continue using ExtDict should fail : one missing byte for output buffer");
+ FUZ_CHECKTEST(ret>0, "LZ4_compress_limitedOutput_continue using ExtDict should fail : one missing byte for output buffer : %i written, %i buffer", ret, blockContinueCompressedSize);
FUZ_DISPLAYTEST;
LZ4_loadDict(&LZ4dict, dict, dictSize);