diff options
Diffstat (limited to 'libjava/classpath/java/util/zip')
-rw-r--r-- | libjava/classpath/java/util/zip/InflaterHuffmanTree.java | 7 | ||||
-rw-r--r-- | libjava/classpath/java/util/zip/ZipFile.java | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/libjava/classpath/java/util/zip/InflaterHuffmanTree.java b/libjava/classpath/java/util/zip/InflaterHuffmanTree.java index c12c732..1a152d2 100644 --- a/libjava/classpath/java/util/zip/InflaterHuffmanTree.java +++ b/libjava/classpath/java/util/zip/InflaterHuffmanTree.java @@ -95,11 +95,14 @@ class InflaterHuffmanTree blCount[bits]++; } + int max = 0; int code = 0; int treeSize = 512; for (int bits = 1; bits <= MAX_BITLEN; bits++) { nextCode[bits] = code; + if (blCount[bits] > 0) + max = bits; code += blCount[bits] << (16 - bits); if (bits >= 10) { @@ -109,8 +112,8 @@ class InflaterHuffmanTree treeSize += (end - start) >> (16 - bits); } } - if (code != 65536) - throw new DataFormatException("Code lengths don't add up properly."); + if (code != 65536 && max > 1) + throw new DataFormatException("incomplete dynamic bit lengths tree"); /* Now create and fill the extra tables from longest to shortest * bit len. This way the sub trees will be aligned. diff --git a/libjava/classpath/java/util/zip/ZipFile.java b/libjava/classpath/java/util/zip/ZipFile.java index 3963bcb..b582c84 100644 --- a/libjava/classpath/java/util/zip/ZipFile.java +++ b/libjava/classpath/java/util/zip/ZipFile.java @@ -261,7 +261,10 @@ public class ZipFile implements ZipConstants if (inp.readLeInt() != CENSIG) throw new ZipException("Wrong Central Directory signature: " + name); - inp.skip(6); + inp.skip(4); + int flags = inp.readLeShort(); + if ((flags & 1) != 0) + throw new ZipException("invalid CEN header (encrypted entry)"); int method = inp.readLeShort(); int dostime = inp.readLeInt(); int crc = inp.readLeInt(); |