commit
0bd7dafc93
@ -121,10 +121,9 @@
|
||||
/*-************************************
|
||||
* Compiler Options
|
||||
**************************************/
|
||||
#ifdef _MSC_VER /* Visual Studio */
|
||||
# include <intrin.h>
|
||||
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
||||
# pragma warning(disable : 4293) /* disable: C4293: too large shift (32-bits) */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400) /* Visual Studio 2005+ */
|
||||
# include <intrin.h> /* only present in VS2005+ */
|
||||
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifndef LZ4_FORCE_INLINE
|
||||
|
@ -172,7 +172,8 @@ static unsigned
|
||||
LZ4HC_countPattern(const BYTE* ip, const BYTE* const iEnd, U32 const pattern32)
|
||||
{
|
||||
const BYTE* const iStart = ip;
|
||||
reg_t const pattern = (sizeof(pattern)==8) ? (reg_t)pattern32 + (((reg_t)pattern32) << 32) : pattern32;
|
||||
reg_t const pattern = (sizeof(pattern)==8) ?
|
||||
(reg_t)pattern32 + (((reg_t)pattern32) << (sizeof(pattern)*4)) : pattern32;
|
||||
|
||||
while (likely(ip < iEnd-(sizeof(pattern)-1))) {
|
||||
reg_t const diff = LZ4_read_ARCH(ip) ^ pattern;
|
||||
|
@ -594,15 +594,15 @@ UTIL_createFileList(const char** inputNames, unsigned inputNamesNb,
|
||||
|
||||
for (i=0, pos=0, nbFiles=0; i<inputNamesNb; i++) {
|
||||
if (!UTIL_isDirectory(inputNames[i])) {
|
||||
size_t const len = strlen(inputNames[i]);
|
||||
size_t const len = strlen(inputNames[i]) + 1; /* include nul char */
|
||||
if (pos + len >= bufSize) {
|
||||
while (pos + len >= bufSize) bufSize += LIST_SIZE_INCREASE;
|
||||
buf = (char*)UTIL_realloc(buf, bufSize);
|
||||
if (!buf) return NULL;
|
||||
}
|
||||
assert(pos + len < bufSize);
|
||||
strncpy(buf + pos, inputNames[i], bufSize - pos);
|
||||
pos += len + 1;
|
||||
memcpy(buf + pos, inputNames[i], len);
|
||||
pos += len;
|
||||
nbFiles++;
|
||||
} else {
|
||||
char* bufend = buf + bufSize;
|
||||
|
@ -23,15 +23,6 @@
|
||||
- LZ4 source repository : https://github.com/lz4/lz4
|
||||
*/
|
||||
|
||||
/*-************************************
|
||||
* Compiler specific
|
||||
**************************************/
|
||||
#ifdef _MSC_VER /* Visual Studio */
|
||||
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
||||
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
|
||||
#endif
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Includes
|
||||
**************************************/
|
||||
|
@ -27,8 +27,7 @@
|
||||
* Compiler specific
|
||||
**************************************/
|
||||
#ifdef _MSC_VER /* Visual Studio */
|
||||
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
||||
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
|
||||
# pragma warning(disable : 26451) /* disable: Arithmetic overflow */
|
||||
#endif
|
||||
|
||||
|
||||
@ -1061,7 +1060,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
|
||||
CHECK(op[dstEndSize] != canaryByte, "LZ4F_compressEnd writes beyond dstCapacity !");
|
||||
if (LZ4F_isError(flushedSize)) {
|
||||
if (tooSmallDstEnd) /* failure is allowed */ continue;
|
||||
CHECK(1, "Compression completion failed (error %i : %s)",
|
||||
CHECK(!tooSmallDstEnd, "Compression completion failed (error %i : %s)",
|
||||
(int)flushedSize, LZ4F_getErrorName(flushedSize));
|
||||
}
|
||||
op += flushedSize;
|
||||
|
@ -1097,7 +1097,7 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
{ int const dSize = LZ4_decompress_safe(testCompressed, testVerify, cSize, testInputSize);
|
||||
assert(dSize == sampleSize); /* correct size */
|
||||
{ XXH32_hash_t const crcCheck = XXH32(testVerify, (size_t)dSize, 0);
|
||||
assert(crcCheck == crcOrig);
|
||||
FUZ_CHECKTEST(crcCheck != crcOrig, "LZ4_decompress_safe decompression corruption");
|
||||
} } }
|
||||
DISPLAYLEVEL(3, " OK \n");
|
||||
|
||||
@ -1121,7 +1121,7 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
{ int const dSize = LZ4_decompress_safe(startInput, testVerify, cSize, sampleSize);
|
||||
assert(dSize == sampleSize); /* correct size */
|
||||
{ XXH64_hash_t const crcCheck = XXH64(testVerify, (size_t)dSize, 0);
|
||||
assert(crcCheck == crcOrig);
|
||||
FUZ_CHECKTEST(crcCheck != crcOrig, "LZ4_decompress_safe decompression corruption");
|
||||
} } } } }
|
||||
DISPLAYLEVEL(3, " OK \n");
|
||||
|
||||
@ -1173,12 +1173,12 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
assert(ctx != NULL); /* ensure init is successful */
|
||||
|
||||
/* Check access violation with asan */
|
||||
FUZ_CHECKTEST( LZ4_saveDict(&streamingState, NULL, 0) != 0,
|
||||
FUZ_CHECKTEST( LZ4_saveDict(ctx, NULL, 0) != 0,
|
||||
"LZ4_saveDict() can't save anything into (NULL,0)");
|
||||
|
||||
/* Check access violation with asan */
|
||||
{ char tmp_buffer[240] = { 0 };
|
||||
FUZ_CHECKTEST( LZ4_saveDict(&streamingState, tmp_buffer, sizeof(tmp_buffer)) != 0,
|
||||
FUZ_CHECKTEST( LZ4_saveDict(ctx, tmp_buffer, sizeof(tmp_buffer)) != 0,
|
||||
"LZ4_saveDict() can't save anything since compression hasn't started");
|
||||
} }
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
@ -1290,12 +1290,12 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
assert(ctx != NULL); /* ensure init is successful */
|
||||
|
||||
/* Check access violation with asan */
|
||||
FUZ_CHECKTEST( LZ4_saveDictHC(&sHC, NULL, 0) != 0,
|
||||
FUZ_CHECKTEST( LZ4_saveDictHC(ctx, NULL, 0) != 0,
|
||||
"LZ4_saveDictHC() can't save anything into (NULL,0)");
|
||||
|
||||
/* Check access violation with asan */
|
||||
{ char tmp_buffer[240] = { 0 };
|
||||
FUZ_CHECKTEST( LZ4_saveDictHC(&sHC, tmp_buffer, sizeof(tmp_buffer)) != 0,
|
||||
FUZ_CHECKTEST( LZ4_saveDictHC(ctx, tmp_buffer, sizeof(tmp_buffer)) != 0,
|
||||
"LZ4_saveDictHC() can't save anything since compression hasn't started");
|
||||
} }
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
@ -1596,7 +1596,7 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
|
||||
DISPLAYLEVEL(3, "LZ4_compress_HC_destSize : ");
|
||||
/* encode congenerical sequence test for HC compressors */
|
||||
{ LZ4_streamHC_t sHC; /* statically allocated */
|
||||
{ LZ4_streamHC_t* const sHC = LZ4_createStreamHC();
|
||||
int const src_buf_size = 3 MB;
|
||||
int const dst_buf_size = 6 KB;
|
||||
int const payload = 0;
|
||||
@ -1609,6 +1609,7 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
char* dbuf1 = (char*)malloc(dst_buf_size + 1);
|
||||
char* dbuf2 = (char*)malloc(dst_buf_size + 1);
|
||||
|
||||
assert(sHC != NULL);
|
||||
assert(dst_buf_size > dst_max_len);
|
||||
if (!sbuf1 || !sbuf2 || !dbuf1 || !dbuf2) {
|
||||
EXIT_MSG("not enough memory for FUZ_unitTests (destSize)");
|
||||
@ -1643,8 +1644,8 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
memset(sbuf2, payload, slen);
|
||||
memset(dbuf2, 0, dlen);
|
||||
dbuf2[dlen] = endchk;
|
||||
LZ4_resetStreamHC(&sHC, compressionLevel);
|
||||
dsz2 = LZ4_compress_HC_destSize(&sHC, sbuf2, dbuf2, &srcsz2, dlen, compressionLevel);
|
||||
LZ4_resetStreamHC(sHC, compressionLevel);
|
||||
dsz2 = LZ4_compress_HC_destSize(sHC, sbuf2, dbuf2, &srcsz2, dlen, compressionLevel);
|
||||
DISPLAYLEVEL(5, "LZ4_compress_HC_destSize: %i bytes compressed into %i bytes, ", srcsz2, dsz2);
|
||||
DISPLAYLEVEL(5, "last token : 0x%0X, ", dbuf2[dsz2 - 6]);
|
||||
DISPLAYLEVEL(5, "last ML extra lenbyte : 0x%0X, \n", dbuf2[dsz2 - 7]);
|
||||
@ -1663,6 +1664,7 @@ static void FUZ_unitTests(int compressionLevel)
|
||||
FUZ_CHECKTEST(memcmp(sbuf1, sbuf2, (size_t)res2), "LZ4_compress_HC_destSize() decompression corruption!");
|
||||
}
|
||||
}
|
||||
LZ4_freeStreamHC(sHC);
|
||||
free(sbuf1);
|
||||
free(sbuf2);
|
||||
free(dbuf1);
|
||||
|
Loading…
Reference in New Issue
Block a user