Hello Ivan,

The JDK also fails to open zip files that contain encrypted entries.

Regards,
Jeroen

> -----Original Message-----
> From: Ivan Maidanski [mailto:iv...@mail.ru]
> Sent: Wednesday, July 14, 2010 7:56 AM
> To: Andrew John Hughes
> Cc: classpath-patches; Daniel Noll; Jeroen Frijters
> Subject: Re[2]: [cp-patches] What's about bug 36560 (Error parsing zip
> file...)?
> 
> Hello, Andrew and Jeroen!
> 
> The patched applied to InflaterHuffmanTree.java is ok.
> But the patch for ZipFile isn't - you just reject any zip file that
> contains a single encrypted file. Mine (or Daniel's) solution is to fail
> only when trying to read from an encrypted zip entry. See classpath-
> ivmai-30.diff
> (http://article.gmane.org/gmane.comp.java.classpath.patches/13013).
> 
> Regards.
> 
> Tue, 13 Jul 2010 17:50:30 +0100 Andrew John Hughes <ahug...@redhat.com>:
> 
> > On 13 July 2010 13:53, Jeroen Frijters <jer...@sumatra.nl> wrote:
> > > Hello,
> > >
> > > I've committed the patch below and closed the bug.
> > >
> >
> > Thanks. I couldn't include the whole of Daniel's patch as he hasn't
> > signed a copyright assignment.
> >
> > > 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.
> > >
> >
> > --
> > Andrew :-)


Reply via email to