You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2013/12/07 08:46:28 UTC
svn commit: r1548804 -
/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
Author: bodewig
Date: Sat Dec 7 07:46:27 2013
New Revision: 1548804
URL: http://svn.apache.org/r1548804
Log:
COMPRESS-147 be extra defensive against overflows - can actually not happen with the current snappy compressors where offset will always be <= 32768
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java?rev=1548804&r1=1548803&r2=1548804&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/snappy/SnappyCompressorInputStream.java Sat Dec 7 07:46:27 2013
@@ -164,7 +164,7 @@ public class SnappyCompressorInputStream
while (readNow > 0) {
final int b = readOneByte();
int length = 0;
- int offset = 0;
+ long offset = 0;
switch (b & TAG_MASK) {
@@ -329,7 +329,7 @@ public class SnappyCompressorInputStream
* backreferences that would go past the end of the block (offset > current
* decompressed position), which is also nonsensical and thus not allowed.
*
- * @param offset
+ * @param off
* The offset from the backward from the end of expanded stream
* @param length
* The number of bytes to copy
@@ -339,10 +339,11 @@ public class SnappyCompressorInputStream
* buffer
* @return True if the decompressed data should be flushed
*/
- private boolean expandCopy(final int offset, int length) throws IOException {
- if (offset > blockSize) {
+ private boolean expandCopy(final long off, int length) throws IOException {
+ if (off > blockSize) {
throw new IOException("Offset is larger than block size");
}
+ int offset = (int) off;
if (offset == 1) {
byte lastChar = decompressBuf[writeIndex - 1];