public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libgcj/1268: java/util/zip/ZipFile reads directory incorrectly
@ 2000-12-20 12:23 Kresten Krab Thorup
  0 siblings, 0 replies; only message in thread
From: Kresten Krab Thorup @ 2000-12-20 12:23 UTC (permalink / raw)
  To: java-gnats

>Number:         1268
>Category:       libgcj
>Synopsis:       java/util/zip/ZipFile reads directory incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    java-hacker
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:18:30 PST 2000
>Closed-Date:    Sun Apr 02 20:27:35 PDT 2000
>Last-Modified:  Sun Apr  2 20:30:01 PDT 2000
>Originator:     Kresten Krab Thorup <krab@gnu.org>
>Release:        snapshot aug-09-99 20:00
>Organization:
>Environment:

>Description:
The ZipFile class does not read the zip file central 
directory correctly.
The result is, that classes cannot be loaded from
zip or jar files.  The class loader reports 
"erroneous magic number".
>How-To-Repeat:
Run the verifier (available from krab@gnu.org) on itself,

  gij verify.Tool --classpath=.:path/to/libgcj.zip

This will trigger the verifier to load class 
java.lang.String from the zip file, which will not work.
>Fix:
1999-11-07  Anthony Green  <green@cygnus.com>

        * java/util/zip/ZipFile.java: Compute the offset of the ZipEntry
        data correctly.

Index: libjava/java/util/zip/ZipFile.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/ZipFile.java,v
retrieving revision 1.4
diff -u -r1.4 ZipFile.java
--- ZipFile.java        1999/08/18 14:16:41     1.4
+++ ZipFile.java        1999/11/07 08:18:34
@@ -122,10 +122,13 @@
   public InputStream getInputStream(ZipEntry ze)  throws IOException
   {
     byte[] buffer = new byte[(int) ze.getSize()];
-    int data_offset = ZipConstants.LOCAL_FILE_HEADER_SIZE + name.length();
-    if (ze.extra != null)
-      data_offset += ze.extra.length;
-    file.seek(ze.relativeOffset + data_offset);
+
+    /* Read the size of the extra field, and skip to the start of the
+       data.  */
+    file.seek (ze.relativeOffset + ZipConstants.LOCAL_FILE_HEADER_SIZE - 2);
+    int extraFieldLength = readu2();
+    file.skipBytes (ze.getName().length() + extraFieldLength);
+
     file.readFully(buffer);

     InputStream is = new ByteArrayInputStream (buffer);
>Release-Note:

>Audit-Trail:

Formerly PR java.util/25

Responsible-Changed-From-To: apbianco->java-hacker
Responsible-Changed-By: apbianco
Responsible-Changed-When: Fri Aug 20 00:36:37 1999
Responsible-Changed-Why:
    The reflect the category change from `gcj' to `libgcj'.
State-Changed-From-To: open->feedback
State-Changed-By: green
State-Changed-When: Sun Nov  7 00:33:59 1999
State-Changed-Why:
    I've committed a fix to the problem.  Let me know if it
    works for you and I'll close this.

From: green@cygnus.com
To: green@cygnus.com, java-gnats@sourceware.cygnus.com, krab@gnu.org
Cc:  
Subject: Re: java.util/25
Date: 7 Nov 1999 08:33:59 -0000

 Synopsis: java/util/zip/ZipFile reads directory incorrectly
 
 State-Changed-From-To: open->feedback
 State-Changed-By: green
 State-Changed-When: Sun Nov  7 00:33:59 1999
 State-Changed-Why:
     I've committed a fix to the problem.  Let me know if it
     works for you and I'll close this.
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&database=java&pr=25
State-Changed-From-To: feedback->closed
State-Changed-By: green
State-Changed-When: Sun Apr  2 20:27:35 2000
State-Changed-Why:
    This was fixed some time ago.  I'm just going to close it now.

From: green@cygnus.com
To: green@cygnus.com, java-gnats@sourceware.cygnus.com, krab@gnu.org
Cc:  
Subject: Re: java.util/25
Date: 3 Apr 2000 03:27:35 -0000

 Synopsis: java/util/zip/ZipFile reads directory incorrectly
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: green
 State-Changed-When: Sun Apr  2 20:27:35 2000
 State-Changed-Why:
     This was fixed some time ago.  I'm just going to close it now.
 
 http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=25&database=java
>Unformatted:



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-20 12:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-20 12:23 libgcj/1268: java/util/zip/ZipFile reads directory incorrectly Kresten Krab Thorup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).