aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/util/zip/GZIPInputStream.java4
-rw-r--r--libjava/java/util/zip/InflaterInputStream.java16
2 files changed, 19 insertions, 1 deletions
diff --git a/libjava/java/util/zip/GZIPInputStream.java b/libjava/java/util/zip/GZIPInputStream.java
index 9eef73e..5640163 100644
--- a/libjava/java/util/zip/GZIPInputStream.java
+++ b/libjava/java/util/zip/GZIPInputStream.java
@@ -230,7 +230,9 @@ public class GZIPInputStream
tmp[i] = (byte) eof_read();
}
- int header_crc = read4(tmp, 0);
+ // Be careful to avoid sign extension here; CRC32.getValue()
+ // returns a long.
+ long header_crc = read4(tmp, 0) & 0xffffffffL;
if (crc.getValue() != header_crc)
throw new ZipException("corrupted gzip file - crc mismatch");
int isize = read4(tmp, 4);
diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java
index 27c29ff..3676a2c 100644
--- a/libjava/java/util/zip/InflaterInputStream.java
+++ b/libjava/java/util/zip/InflaterInputStream.java
@@ -70,6 +70,9 @@ public class InflaterInputStream extends FilterInputStream
*/
protected int len;
+ // We just use this if we are decoding one byte at a time with the
+ // read() call.
+ private byte[] onebytebuffer = new byte[1];
/**
* Create an InflaterInputStream with the default decompresseor
@@ -156,6 +159,19 @@ public class InflaterInputStream extends FilterInputStream
}
/**
+ * Reads one byte of decompressed data.
+ *
+ * The byte is in the lower 8 bits of the int.
+ */
+ public int read() throws IOException
+ {
+ int nread = read(onebytebuffer, 0, 1);
+ if (nread > 0)
+ return onebytebuffer[0] & 0xff;
+ return -1;
+ }
+
+ /**
* Decompresses data into the byte array
*
* @param b the array to read and decompress data into