Corrected issue 38 : bench.c compilation for Sun Solaris 32 bits

Corrected issue 40 : Detect early ending of compressed stream. Thanks Adrian Grand.
Corrected issue 41 : minor comment editing on lz4.h

git-svn-id: https://lz4.googlecode.com/svn/trunk@82 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2012-11-03 21:04:19 +00:00
parent 206f5f48cf
commit 5cc3efc2a5
3 changed files with 14 additions and 9 deletions

13
bench.c
View File

@ -29,10 +29,15 @@
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE // VS2005
// Under Linux at least, pull in the *64 commands
#define _LARGEFILE64_SOURCE
// Unix Large Files support (>4GB)
#if (defined(__sun__) && (!defined(__LP64__))) // Sun Solaris 32-bits requires specific definitions
# define _LARGEFILE_SOURCE
# define FILE_OFFSET_BITS=64
#else
# define _LARGEFILE64_SOURCE
#endif
// MSVC does not support S_ISREG
// S_ISREG & gettimeofday() are not supported by MSVC
#if defined(_MSC_VER)
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
# define BMK_LEGACY_TIMER 1
@ -40,7 +45,7 @@
// GCC does not support _rotl outside of Windows
#if !defined(_WIN32)
#define _rotl(x,r) ((x << r) | (x >> (32 - r)))
# define _rotl(x,r) ((x << r) | (x >> (32 - r)))
#endif

8
lz4.c
View File

@ -719,10 +719,10 @@ int LZ4_uncompress(const char* source,
cpy = op+length;
if unlikely(cpy>oend-COPYLENGTH)
{
if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer
if (cpy != oend) goto _output_error; // Error : we must necessarily stand at EOF
memcpy(op, ip, length);
ip += length;
break; // Necessarily EOF
break; // EOF
}
LZ4_WILDCOPY(ip, op, cpy); ip -= (op-cpy); op = cpy;
@ -805,13 +805,13 @@ int LZ4_uncompress_unknownOutputSize(
cpy = op+length;
if ((cpy>oend-COPYLENGTH) || (ip+length>iend-COPYLENGTH))
{
if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer
if (cpy != oend) goto _output_error; // Error : we must necessarily stand at EOF
if (ip+length > iend) goto _output_error; // Error : request to read beyond source buffer
memcpy(op, ip, length);
op += length;
ip += length;
if (ip<iend) goto _output_error; // Error : LZ4 format violation
break; // Necessarily EOF, due to parsing restrictions
break; // Necessarily EOF, due to parsing restrictions
}
LZ4_WILDCOPY(ip, op, cpy); ip -= (op-cpy); op = cpy;

2
lz4.h
View File

@ -60,7 +60,7 @@ LZ4_uncompress() :
osize : is the output size, therefore the original size
return : the number of bytes read in the source buffer
If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
This function never writes beyond dest + osize, and is therefore protected against malicious data packets
This function never writes outside of provided buffers, and never modifies input buffer.
note : destination buffer must be already allocated.
its size must be a minimum of 'osize' bytes.
*/