From 7a863abfc2da21cf69fc2db2ad92e9f8e2c72004 Mon Sep 17 00:00:00 2001 From: "yann.collet.73@gmail.com" Date: Sat, 2 Nov 2013 12:11:04 +0000 Subject: lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting) git-svn-id: https://lz4.googlecode.com/svn/trunk@108 650e7d94-2a16-8b24-b05c-7c0b3f6821cd --- Makefile | 2 +- NEWS | 9 ++++++--- lz4.c | 22 ++++++++++++++-------- lz4cli.c | 5 +++-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index cca2a30..bacc702 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ # fullbench32: Same as fullbench, but forced to compile in 32-bits mode # ################################################################ -RELEASE=r107 +RELEASE=r108 DESTDIR= PREFIX=${DESTDIR}/usr BINDIR=$(PREFIX)/bin diff --git a/NEWS b/NEWS index c158a94..01945ea 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +r108 : +lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting) + r107 : Makefile : support DESTDIR for staged installs. Thanks Jorge Aparicio. Makefile : make install installs both lz4 and lz4c (Jorge Aparicio) @@ -13,11 +16,11 @@ cmake : check for just C compiler (Elan Ruusamae) r106 : Makefile : make dist modify text files in the package to respect Unix EoL convention -lz4cli : corrected small display bug in HC mode +lz4cli.c : corrected small display bug in HC mode r105 : Makefile : New install script and man page, contributed by Prasad Pandit lz4cli.c : Minor modifications, for easier extensibility -COPYING : added license file +COPYING : added license file LZ4_Streaming_Format.odt : modified file name to remove white space characters -exe : .exe suffix now properly added only for Windows target \ No newline at end of file +Makefile : .exe suffix now properly added only for Windows target \ No newline at end of file diff --git a/lz4.c b/lz4.c index 2d014ca..5668521 100644 --- a/lz4.c +++ b/lz4.c @@ -631,21 +631,27 @@ char* LZ4_slideInputBuffer (void* LZ4_Data) LZ4_Data_Structure* lz4ds = (LZ4_Data_Structure*)LZ4_Data; size_t delta = lz4ds->nextBlock - (lz4ds->bufferStart + 64 KB); - if(lz4ds->base - delta > lz4ds->base) // underflow control + if ( (lz4ds->base - delta > lz4ds->base) // underflow control + || ((size_t)(lz4ds->nextBlock - lz4ds->base) > 0xE0000000) ) // close to 32-bits limit { - size_t newBaseDelta = (lz4ds->nextBlock - 64 KB) - lz4ds->base; + size_t deltaLimit = (lz4ds->nextBlock - 64 KB) - lz4ds->base; int nH; for (nH=0; nH < HASHNBCELLS4; nH++) { - if (lz4ds->hashTable[nH] < (U32)newBaseDelta) lz4ds->hashTable[nH] = 0; - else lz4ds->hashTable[nH] -= (U32)newBaseDelta; + if ((size_t)(lz4ds->hashTable[nH]) < deltaLimit) lz4ds->hashTable[nH] = 0; + else lz4ds->hashTable[nH] -= (U32)deltaLimit; } - lz4ds->base += newBaseDelta; + memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB); + lz4ds->base = lz4ds->bufferStart; + lz4ds->nextBlock = lz4ds->base + 64 KB; } - memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB); - lz4ds->nextBlock -= delta; - lz4ds->base -= delta; + else + { + memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB); + lz4ds->nextBlock -= delta; + lz4ds->base -= delta; + } return (char*)(lz4ds->nextBlock); } diff --git a/lz4cli.c b/lz4cli.c index 4743115..5375ac6 100644 --- a/lz4cli.c +++ b/lz4cli.c @@ -49,7 +49,8 @@ #endif #define _FILE_OFFSET_BITS 64 // Large file support on 32-bits unix -#define _POSIX_SOURCE 1 // for fileno() within on unix +#define _POSIX_SOURCE 1 // for fileno() within on unix + //**************************** // Includes @@ -106,7 +107,7 @@ // Constants //**************************** #define COMPRESSOR_NAME "LZ4 Compression CLI" -#define COMPRESSOR_VERSION "v1.0.7" +#define COMPRESSOR_VERSION "v1.0.8" #define COMPILED __DATE__ #define AUTHOR "Yann Collet" #define LZ4_EXTENSION ".lz4" -- cgit v0.12