diff --git a/src/java/net/jpountz/lz4/LZ4BlockInputStream.java b/src/java/net/jpountz/lz4/LZ4BlockInputStream.java index 23fd5e3..30e63e3 100644 --- a/src/java/net/jpountz/lz4/LZ4BlockInputStream.java +++ b/src/java/net/jpountz/lz4/LZ4BlockInputStream.java @@ -257,7 +257,7 @@ private void refill() throws IOException { } checksum.reset(); checksum.update(buffer, 0, originalLen); - if ((int) checksum.getValue() != check) { + if ((int) (checksum.getValue() & 0x0FFFFFFF) != check) { throw new IOException("Stream is corrupted"); } o = 0; diff --git a/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java b/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java index 623eb1c..063f922 100644 --- a/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java +++ b/src/java/net/jpountz/lz4/LZ4BlockOutputStream.java @@ -206,7 +206,7 @@ private void flushBufferedData() throws IOException { } checksum.reset(); checksum.update(buffer, 0, o); - final int check = (int) checksum.getValue(); + final int check = (int) (checksum.getValue() & 0x0FFFFFFF); int compressedLength = compressor.compress(buffer, 0, o, compressedBuffer, HEADER_LENGTH); final int compressMethod; if (compressedLength >= o) { diff --git a/src/java/net/jpountz/xxhash/StreamingXXHash32.java b/src/java/net/jpountz/xxhash/StreamingXXHash32.java index 8143433..eb5f608 100644 --- a/src/java/net/jpountz/xxhash/StreamingXXHash32.java +++ b/src/java/net/jpountz/xxhash/StreamingXXHash32.java @@ -103,7 +103,7 @@ public final Checksum asChecksum() { @Override public long getValue() { - return StreamingXXHash32.this.getValue() & 0xFFFFFFFL; + return StreamingXXHash32.this.getValue() & 0xFFFFFFFFL; } @Override