From 9577c977a90bc85eaa2fe8550202a2cdf15b1e5f Mon Sep 17 00:00:00 2001 From: "yann.collet.73@gmail.com" Date: Wed, 22 Aug 2012 15:59:39 +0000 Subject: Correction : LZ4_compress_limitedOutput() write too far error git-svn-id: https://lz4.googlecode.com/svn/trunk@77 650e7d94-2a16-8b24-b05c-7c0b3f6821cd --- lz4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lz4.c b/lz4.c index 8bb7a45..eeefa67 100644 --- a/lz4.c +++ b/lz4.c @@ -449,6 +449,7 @@ _endCount: // Encode MatchLength len = (int)(ip - anchor); + if unlikely(op + (1 + LASTLITERALS) + (len>>8) >= oend) return 0; // Check output limit if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; } else *token += len; @@ -613,6 +614,7 @@ _endCount: // Encode MatchLength len = (int)(ip - anchor); + if unlikely(op + (1 + LASTLITERALS) + (len>>8) >= oend) return 0; // Check output limit if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; } else *token += len; -- cgit v0.12