[Bug java/14446] GZIPInputStream: corrupted gzip file - crc mismatch

sorabain at hotmail dot com gcc-bugzilla@gcc.gnu.org
Wed Sep 22 16:02:00 GMT 2004


------- Additional Comments From sorabain at hotmail dot com  2004-09-22 16:02 -------
We had the same problem, and i found the cause: 
java.util.zip.GZIPInputStream.java in libjava has a method called read4() that 
reads in 4 bytes and returns them as an int (java integers are signed). this 
is compared to CRC32.getValue(), which returns a long. The int is promoted to 
a long for the comparison, but if the most significant (sign) bit is set this 
will be a negative number, whereas the long with the same original low 32-bits 
is positive. The comparison fails.

To fix it i just changed the return type of read4() to be a long in-line with 
the type of CRC32.getValue()

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446



More information about the Gcc-bugs mailing list