From c4f5b9de2a6483e4a2c962e2c7a0037fe42aee59 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 5 Jun 2014 01:59:19 +0100 Subject: Fixed (continued) : address space overflow in 32-bits mode --- lz4.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lz4.c b/lz4.c index 0f1ee7a..cb5c3db 100755 --- a/lz4.c +++ b/lz4.c @@ -742,6 +742,10 @@ int LZ4_compress_usingDict (LZ4_dict_t* LZ4_dict, const char* source, char* dest LZ4_dict_t_internal* streamPtr = (LZ4_dict_t_internal*)LZ4_dict; const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize; + const BYTE* smallest = dictEnd; + if (smallest > (const BYTE*) source) smallest = (const BYTE*) source; + LZ4_renormDictT((LZ4_dict_t_internal*)LZ4_dict, smallest); + if (dictEnd == (const BYTE*)source) { int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, 0, notLimited, byU32, withPrefix64k); @@ -764,6 +768,10 @@ int LZ4_compress_limitedOutput_usingDict (LZ4_dict_t* LZ4_dict, const char* sour LZ4_dict_t_internal* streamPtr = (LZ4_dict_t_internal*)LZ4_dict; const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize; + const BYTE* smallest = dictEnd; + if (smallest > (const BYTE*) source) smallest = (const BYTE*) source; + LZ4_renormDictT((LZ4_dict_t_internal*)LZ4_dict, smallest); + if (dictEnd == (const BYTE*)source) { int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k); -- cgit v0.12