aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-12-16 02:13:19 +0100
committerMohamad Ayyash <mkayyash@google.com>2015-02-23 17:26:23 -0800
commitb00f7a053658a719a440c702e4123e0349f035e9 (patch)
tree7075803326038ca6f79e36cdcfc7b854efa9f0b1
parent17f5eaeb9e846a0e8065b6d6316b620927ab90e2 (diff)
downloadlz4-b00f7a053658a719a440c702e4123e0349f035e9.tar.gz
Fixed : bug within LZ4 HC streaming mode, reported by James Boyle
-rw-r--r--NEWS3
-rw-r--r--lib/lz4.c2
-rw-r--r--lib/lz4hc.c1
-rw-r--r--programs/Makefile1
-rw-r--r--programs/datagen.c41
5 files changed, 27 insertions, 21 deletions
diff --git a/NEWS b/NEWS
index 67f63a41..21c54dc4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
r126:
New : lz4frame API is now integrated into liblz4
-Fixed : GCC 4.9 bug on highest performance settings, reported by Greg Slazinski
+Fixed : GCC 4.9 bug on highest performance settings, reported by Greg Slazinski
+Fixed : bug within LZ4 HC streaming mode, reported by James Boyle
r125:
Changed : endian and alignment code
diff --git a/lib/lz4.c b/lib/lz4.c
index d6225840..a3653751 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -541,7 +541,7 @@ static int LZ4_compress_generic(
break;
}
if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */
- if (inputSize<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
+ if (inputSize<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
/* First Byte */
LZ4_putPosition(ip, ctx, tableType, base);
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index 45f12089..ef3997b8 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -693,6 +693,7 @@ int LZ4_saveDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, char* safeBuffer, int dictS
streamPtr->base = streamPtr->end - endIndex;
streamPtr->dictLimit = endIndex - dictSize;
streamPtr->lowLimit = endIndex - dictSize;
+ if (streamPtr->nextToUpdate < streamPtr->dictLimit) streamPtr->nextToUpdate = streamPtr->dictLimit;
}
return dictSize;
}
diff --git a/programs/Makefile b/programs/Makefile
index f097d06d..67218c1b 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -142,6 +142,7 @@ test-travis: $(TRAVIS_TARGET)
test-lz4: lz4 datagen
./datagen -g16KB | ./lz4 -9 | ./lz4 -vdq > $(VOID)
./datagen | ./lz4 | ./lz4 -vdq > $(VOID)
+ ./datagen -g6M -p100 | ./lz4 -9BD | ./lz4 -vdq > $(VOID)
./datagen -g256MB | ./lz4 -vqB4D | ./lz4 -vdq > $(VOID)
./datagen -g6GB | ./lz4 -vqB5D | ./lz4 -vdq > $(VOID)
# test frame concatenation with null-length frame
diff --git a/programs/datagen.c b/programs/datagen.c
index 706c30fa..0f074774 100644
--- a/programs/datagen.c
+++ b/programs/datagen.c
@@ -1,6 +1,7 @@
/*
datagen.c - compressible data generator test tool
- Copyright (C) Yann Collet 2012-2014
+ Copyright (C) Yann Collet 2012-2015
+
GPL v2 License
This program is free software; you can redistribute it and/or modify
@@ -18,8 +19,9 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
You can contact the author at :
- - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
- - LZ4 source repository : http://code.google.com/p/lz4/
+ - LZ4 source repository : http://code.google.com/p/lz4
+ - LZ4 source mirror : https://github.com/Cyan4973/lz4
+ - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
*/
/**************************************
@@ -31,7 +33,6 @@
/**************************************
Includes
**************************************/
-//#include <stdlib.h>
#include <stdio.h> // fgets, sscanf
#include <string.h> // strcmp
@@ -59,11 +60,11 @@
Constants
**************************************/
#ifndef LZ4_VERSION
-# define LZ4_VERSION "rc118"
+# define LZ4_VERSION "r125"
#endif
-#define KB *(1U<<10)
-#define MB *(1U<<20)
+#define KB *(1 <<10)
+#define MB *(1 <<20)
#define GB *(1U<<30)
#define CDG_SIZE_DEFAULT (64 KB)
@@ -83,13 +84,13 @@
/**************************************
Local Parameters
**************************************/
-static int no_prompt = 0;
-static char* programName;
-static int displayLevel = 2;
+static unsigned no_prompt = 0;
+static char* programName;
+static unsigned displayLevel = 2;
/*********************************************************
- Fuzzer functions
+ functions
*********************************************************/
#define CDG_rotl32(x,r) ((x << r) | (x >> (32 - r)))
@@ -113,10 +114,11 @@ static void CDG_generate(U64 size, U32* seed, double proba)
BYTE* buff = fullbuff + 32 KB;
U64 total=0;
U32 P32 = (U32)(32768 * proba);
- U32 pos=0;
+ U32 pos=1;
U32 genBlockSize = 128 KB;
// Build initial prefix
+ fullbuff[0] = CDG_RANDCHAR;
while (pos<32 KB)
{
// Select : Literal (char) or Match (within 32K)
@@ -135,9 +137,7 @@ static void CDG_generate(U64 size, U32* seed, double proba)
else
{
// Literal (noise)
- U32 d;
- int length = CDG_RANDLENGTH;
- d = pos + length;
+ U32 d = pos + CDG_RANDLENGTH;
while (pos < d) fullbuff[pos++] = CDG_RANDCHAR;
}
}
@@ -175,8 +175,10 @@ static void CDG_generate(U64 size, U32* seed, double proba)
while (pos < d) buff[pos++] = CDG_RANDCHAR;
}
}
+ // output datagen
pos=0;
- for (;pos+512<=genBlockSize;pos+=512) printf("%512.512s", buff+pos);
+ for (;pos+512<=genBlockSize;pos+=512)
+ printf("%512.512s", buff+pos);
for (;pos<genBlockSize;pos++) printf("%c", buff[pos]);
// Regenerate prefix
memcpy(fullbuff, buff + 96 KB, 32 KB);
@@ -215,13 +217,13 @@ int main(int argc, char** argv)
if(!argument) continue; // Protection if argument empty
// Decode command (note : aggregated commands are allowed)
- if (argument[0]=='-')
+ if (*argument=='-')
{
if (!strcmp(argument, "--no-prompt")) { no_prompt=1; continue; }
- while (argument[1]!=0)
+ argument++;
+ while (*argument!=0)
{
- argument++;
switch(*argument)
{
case 'h':
@@ -264,6 +266,7 @@ int main(int argc, char** argv)
break;
case 'v':
displayLevel = 4;
+ argument++;
break;
default: ;
}