summaryrefslogtreecommitdiffstats
path: root/lz4.c
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-06-04 21:34:48 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-06-04 21:34:48 (GMT)
commit140e6e72ddb6fc5f7cd28ce0c8ec3812ef4a9c08 (patch)
treeae8dea438b399191b6d7afe8f1e646e0189b8baf /lz4.c
parent1e053a290ab55af5d03eae209e9ee64f555670b7 (diff)
downloadlz4-140e6e72ddb6fc5f7cd28ce0c8ec3812ef4a9c08.zip
lz4-140e6e72ddb6fc5f7cd28ce0c8ec3812ef4a9c08.tar.gz
lz4-140e6e72ddb6fc5f7cd28ce0c8ec3812ef4a9c08.tar.bz2
Corrected : address space overflow in 32-bits mode
Diffstat (limited to 'lz4.c')
-rwxr-xr-xlz4.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lz4.c b/lz4.c
index 4c84e92..0f1ee7a 100755
--- a/lz4.c
+++ b/lz4.c
@@ -718,9 +718,10 @@ int LZ4_loadDict (LZ4_dict_t* LZ4_dict, const char* dictionary, int dictSize)
}
-void LZ4_renormDictT(LZ4_dict_t_internal* LZ4_dict)
+void LZ4_renormDictT(LZ4_dict_t_internal* LZ4_dict, const BYTE* src)
{
- if (LZ4_dict->currentOffset > 0x80000000)
+ if ((LZ4_dict->currentOffset > 0x80000000) ||
+ (src - LZ4_dict->currentOffset > src)) /* address space overflow */
{
/* rescale hash table */
U32 delta = LZ4_dict->currentOffset - 64 KB;
@@ -731,6 +732,7 @@ void LZ4_renormDictT(LZ4_dict_t_internal* LZ4_dict)
else LZ4_dict->hashTable[i] -= delta;
}
LZ4_dict->currentOffset = 64 KB;
+ LZ4_dict->dictionary = src - 64 KB;
}
}
@@ -807,7 +809,7 @@ int LZ4_moveDict (LZ4_dict_t* LZ4_dict, char* safeBuffer, int dictSize)
dict->dictionary = (const BYTE*)safeBuffer;
dict->dictSize = (U32)dictSize;
- LZ4_renormDictT(dict);
+ LZ4_renormDictT(dict, (const BYTE*)safeBuffer);
return 1;
}
@@ -1087,7 +1089,10 @@ char* LZ4_slideInputBuffer (void* LZ4_Data)
int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int inputSize)
{
LZ4_dict_t_internal* streamPtr = (LZ4_dict_t_internal*)LZ4_Data;
- int result = LZ4_compress_generic(LZ4_Data, source, dest, inputSize, 0, notLimited, byU32, withPrefix64k);
+ int result;
+
+ LZ4_renormDictT(streamPtr, (const BYTE*) source);
+ result = LZ4_compress_generic(LZ4_Data, source, dest, inputSize, 0, notLimited, byU32, withPrefix64k);
if (streamPtr->dictSize == 0) streamPtr->dictionary = (const BYTE*)source;
streamPtr->dictSize += (U32)inputSize;
@@ -1099,7 +1104,10 @@ int LZ4_compress_continue (void* LZ4_Data, const char* source, char* dest, int i
int LZ4_compress_limitedOutput_continue (void* LZ4_Data, const char* source, char* dest, int inputSize, int maxOutputSize)
{
LZ4_dict_t_internal* streamPtr = (LZ4_dict_t_internal*)LZ4_Data;
- int result = LZ4_compress_generic(LZ4_Data, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k);
+ int result;
+
+ LZ4_renormDictT(streamPtr, (const BYTE*) source);
+ result = LZ4_compress_generic(LZ4_Data, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k);
if (streamPtr->dictSize == 0) streamPtr->dictionary = (const BYTE*)source;
streamPtr->dictSize += (U32)inputSize;