diff options
author | yann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd> | 2011-09-15 19:14:57 (GMT) |
---|---|---|
committer | yann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd> | 2011-09-15 19:14:57 (GMT) |
commit | d5a574c3511c036edd6bc09f8c87b30710728b93 (patch) | |
tree | d9299223fb24a2d961a18b48189d565a551a7655 | |
parent | 15d69c39eb921ad402c17cbb4a0e85cf7286fdc4 (diff) | |
download | lz4-d5a574c3511c036edd6bc09f8c87b30710728b93.zip lz4-d5a574c3511c036edd6bc09f8c87b30710728b93.tar.gz lz4-d5a574c3511c036edd6bc09f8c87b30710728b93.tar.bz2 |
Corrected : a bug in compression function which could make it read beyond input buffer in some circumstances (issue 2).
Many thanks for the detailed bug report.
git-svn-id: https://lz4.googlecode.com/svn/trunk@20 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
-rw-r--r-- | lz4.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -193,14 +193,14 @@ _endCount: }
// Encode Last Literals
- len = length = iend - anchor;
- if (length)
+ len = iend - anchor;
+ if (len)
{
orun=op++;
if (len>=(int)RUN_MASK) { *orun=(RUN_MASK<<ML_BITS); len-=RUN_MASK; for(; len > 254 ; len-=255) *op++ = 255; *op++ = (BYTE) len; }
else *orun = (len<<ML_BITS);
- for(;length>0;length-=4) { *(U32*)op = *(U32*)anchor; op+=4; anchor+=4; }
- op += length; // correction
+ while (anchor < iend - 3) { *(U32*)op = *(U32*)anchor; op+=4; anchor+=4; }
+ while (anchor < iend ) *op++ = *anchor++;
}
// End
|