Fixed wrong byte order in gzip crc32 and isize field

This commit is contained in:
Trustin Lee 2009-10-21 11:23:52 +00:00
parent 05525065b2
commit 8b7efa5db4
2 changed files with 10 additions and 6 deletions

View File

@ -1656,10 +1656,14 @@ final class Deflate {
break; break;
case GZIP: case GZIP:
// Write the gzip trailer (CRC32 & ISIZE) // Write the gzip trailer (CRC32 & ISIZE)
putShortMSB(strm.crc32 >>> 16); put_byte((byte) (strm.crc32 & 0xFF));
putShortMSB(strm.crc32 & 0xFFFF); put_byte((byte) (strm.crc32 >>> 8 & 0xFF));
putShortMSB(gzipUncompressedBytes >>> 16); // ISIZE 1 put_byte((byte) (strm.crc32 >>> 16 & 0xFF));
putShortMSB(gzipUncompressedBytes & 0xFFFF); // ISIZE 2 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; break;
} }

View File

@ -499,7 +499,7 @@ final class Inflate {
z.avail_in --; z.avail_in --;
z.total_in ++; z.total_in ++;
gzipBytesToRead --; 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) { if (z.crc32 != z.istate.gzipCRC32) {
@ -519,7 +519,7 @@ final class Inflate {
z.avail_in --; z.avail_in --;
z.total_in ++; z.total_in ++;
gzipBytesToRead --; 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) { if (gzipUncompressedBytes != z.istate.gzipISize) {