diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java b/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java index 61949fe4e3..9738647c8c 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/Deflate.java @@ -1656,10 +1656,14 @@ final class Deflate { break; case GZIP: // Write the gzip trailer (CRC32 & ISIZE) - putShortMSB(strm.crc32 >>> 16); - putShortMSB(strm.crc32 & 0xFFFF); - putShortMSB(gzipUncompressedBytes >>> 16); // ISIZE 1 - putShortMSB(gzipUncompressedBytes & 0xFFFF); // ISIZE 2 + put_byte((byte) (strm.crc32 & 0xFF)); + put_byte((byte) (strm.crc32 >>> 8 & 0xFF)); + put_byte((byte) (strm.crc32 >>> 16 & 0xFF)); + put_byte((byte) (strm.crc32 >>> 24 & 0xFF)); + put_byte((byte) (gzipUncompressedBytes & 0xFF)); + put_byte((byte) (gzipUncompressedBytes >>> 8 & 0xFF)); + put_byte((byte) (gzipUncompressedBytes >>> 16 & 0xFF)); + put_byte((byte) (gzipUncompressedBytes >>> 24 & 0xFF)); break; } diff --git a/src/main/java/org/jboss/netty/util/internal/jzlib/Inflate.java b/src/main/java/org/jboss/netty/util/internal/jzlib/Inflate.java index 972cd7618b..3f1f19723b 100644 --- a/src/main/java/org/jboss/netty/util/internal/jzlib/Inflate.java +++ b/src/main/java/org/jboss/netty/util/internal/jzlib/Inflate.java @@ -499,7 +499,7 @@ final class Inflate { z.avail_in --; z.total_in ++; gzipBytesToRead --; - z.istate.gzipCRC32 = z.istate.gzipCRC32 << 8 | z.next_in[z.next_in_index ++] & 0xff; + z.istate.gzipCRC32 |= (z.next_in[z.next_in_index ++] & 0xff) << (3 - gzipBytesToRead) * 8; } if (z.crc32 != z.istate.gzipCRC32) { @@ -519,7 +519,7 @@ final class Inflate { z.avail_in --; z.total_in ++; gzipBytesToRead --; - z.istate.gzipISize = z.istate.gzipISize << 8 | z.next_in[z.next_in_index ++] & 0xff; + z.istate.gzipISize |= (z.next_in[z.next_in_index ++] & 0xff) << (3 - gzipBytesToRead) * 8; } if (gzipUncompressedBytes != z.istate.gzipISize) {