diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-04-20 23:37:07 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-04-20 23:37:07 (GMT) |
commit | a8cb2feffdead7b49a09aad0dc7b13dcff206e5b (patch) | |
tree | 55230bec1e20f8b4676e268f766c8a56c08258e1 | |
parent | 85cac61dd8823886132b4a9c2ff4a43b237da917 (diff) | |
download | lz4-a8cb2feffdead7b49a09aad0dc7b13dcff206e5b.zip lz4-a8cb2feffdead7b49a09aad0dc7b13dcff206e5b.tar.gz lz4-a8cb2feffdead7b49a09aad0dc7b13dcff206e5b.tar.bz2 |
Tolerate Base Pointer Underflow
-rw-r--r-- | lib/lz4hc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index b0325a7..b70d03b 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -97,7 +97,7 @@ static void LZ4HC_init (LZ4HC_CCtx_internal* hc4, const BYTE* start) { uptrval startingOffset = hc4->end - hc4->base; DEBUGLOG(4, "LZ4HC_init(%p, %p)", hc4, start); - if (startingOffset > 1 GB || startingOffset > (uptrval)start) { + if (startingOffset > 1 GB) { LZ4HC_clearTables(hc4); startingOffset = 0; } @@ -898,7 +898,7 @@ void LZ4_attach_HC_dictionary(LZ4_streamHC_t *working_stream, const LZ4_streamHC static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock) { DEBUGLOG(4, "LZ4HC_setExternalDict(%p, %p)", ctxPtr, newBlock); - if (ctxPtr->end >= ctxPtr->base + 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */ + if (ctxPtr->end - ctxPtr->base - ctxPtr->nextToUpdate >= 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3); /* Referencing remaining dictionary content */ /* Only one memory segment for extDict, so any previous extDict is lost at this stage */ ctxPtr->lowLimit = ctxPtr->dictLimit; |