Hello, I've committed the patch below and closed the bug.
Regards, Jeroen Index: InflaterHuffmanTree.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/InflaterHuffmanTree.java,v retrieving revision 1.7 diff -u -r1.7 InflaterHuffmanTree.java --- InflaterHuffmanTree.java 3 Jun 2010 19:13:21 -0000 1.7 +++ InflaterHuffmanTree.java 13 Jul 2010 12:42:57 -0000 @@ -95,11 +95,14 @@ 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 @@ 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. > -----Original Message----- > From: classpath-patches-boun...@gnu.org [mailto:classpath-patches- > boun...@gnu.org] On Behalf Of Ivan Maidanski > Sent: Monday, June 28, 2010 9:41 AM > To: classpath-patches > Cc: Daniel Noll; Andrew John Hughes > Subject: [cp-patches] What's about bug 36560 (Error parsing zip > file...)? > > Hello! > > Andrew - > could you apply the proposed patch > (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18682&action=view) and > close bug 36560? > > I can't immediately propose the test case for this bug but I've > discovered this issue when tried to use Classpath > Inflater/InflaterInputStream with OpenJDK PNGImageReader - on some > legacy .png files a ZipException("Code lengths don't add up properly") > was thrown while OpenJDK Inflater (based on zlib) worked correctly. The > patch proposed by Daniel Noll solved my problem. > > Regards.