summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-11-03 21:04:19 (GMT)
committeryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-11-03 21:04:19 (GMT)
commit5cc3efc2a5309b0047a80c9eff4675d38a11201d (patch)
tree330685909ae8def9b3a1ac32c44bcc7350fe9d05
parent206f5f48cf4db19dad3de3adca1d95db335555e0 (diff)
downloadlz4-5cc3efc2a5309b0047a80c9eff4675d38a11201d.zip
lz4-5cc3efc2a5309b0047a80c9eff4675d38a11201d.tar.gz
lz4-5cc3efc2a5309b0047a80c9eff4675d38a11201d.tar.bz2
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
-rw-r--r--bench.c13
-rw-r--r--lz4.c8
-rw-r--r--lz4.h2
3 files changed, 14 insertions, 9 deletions
diff --git a/bench.c b/bench.c
index a48029d..b0a0ecb 100644
--- a/bench.c
+++ b/bench.c
@@ -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
diff --git a/lz4.c b/lz4.c
index 18c4604..3e472a4 100644
--- a/lz4.c
+++ b/lz4.c
@@ -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;
diff --git a/lz4.h b/lz4.h
index 100b3ce..dee3984 100644
--- a/lz4.h
+++ b/lz4.h
@@ -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.
*/