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 2018/01/08 08:03:20 UTC
commons-compress git commit: COMPRESS-38ß block length is an unsigned 32bit int in C code
Repository: commons-compress
Updated Branches:
refs/heads/COMPRESS-380 2d25368dd -> 3600a5f51
COMPRESS-38ß block length is an unsigned 32bit int in C code
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/3600a5f5
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/3600a5f5
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/3600a5f5
Branch: refs/heads/COMPRESS-380
Commit: 3600a5f510cee298397d5ffc21c978ab6e52a160
Parents: 2d25368
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon Jan 8 08:33:32 2018 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon Jan 8 08:33:32 2018 +0100
----------------------------------------------------------------------
.../compress/compressors/deflate64/HuffmanDecoder.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3600a5f5/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
index 5ed4079..8b006c3 100644
--- a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
+++ b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
@@ -141,7 +141,7 @@ class HuffmanDecoder implements Closeable {
//noinspection DuplicateStringLiteralInspection
throw new IllegalStateException("Illegal LEN / NLEN values");
}
- state = new UncompressedState((int) bLen);
+ state = new UncompressedState(bLen);
break;
case 1:
state = new HuffmanCodes(FIXED_CODES, FIXED_LITERALS, FIXED_DISTANCE);
@@ -183,10 +183,10 @@ class HuffmanDecoder implements Closeable {
}
private class UncompressedState extends DecoderState {
- private final int blockLength;
- private int read;
+ private final long blockLength;
+ private long read;
- private UncompressedState(int blockLength) {
+ private UncompressedState(long blockLength) {
this.blockLength = blockLength;
}
@@ -197,7 +197,8 @@ class HuffmanDecoder implements Closeable {
@Override
int read(byte[] b, int off, int len) throws IOException {
- int max = Math.min(blockLength - read, len);
+ // as len is an int the min must fit into an int as well
+ int max = (int) Math.min(blockLength - read, len);
for (int i = 0; i < max; i++) {
byte next = (byte) (readBits(Byte.SIZE) & 0xFF);
b[off + i] = memory.add(next);