ZipFile.java: Compute the offset of the ZipEntry data correctly.
authorAnthony Green <green@trip.cygnus.com>
Sun, 7 Nov 1999 08:30:31 +0000 (08:30 +0000)
committerAnthony Green <green@gcc.gnu.org>
Sun, 7 Nov 1999 08:30:31 +0000 (08:30 +0000)
        * java/util/zip/ZipFile.java: Compute the offset of the ZipEntry
        data correctly.

From-SVN: r30439

libjava/ChangeLog
libjava/java/util/zip/ZipFile.java

index e2abca3d8193a1a637e06179df2e58c9a82e536a..4e3bac9d4dee2595d0502fb958d2b31a98057cc5 100644 (file)
@@ -1,3 +1,8 @@
+1999-11-07  Anthony Green  <green@trip.cygnus.com>
+
+       * java/util/zip/ZipFile.java: Compute the offset of the ZipEntry
+       data correctly.
+
 1999-11-05  Tom Tromey  <tromey@cygnus.com>
 
        * java/lang/natThread.cc (destroy): Removed incorrect comment.
index 1b0ebcee8baeeea3daff25c682c0b7b23b7ab42b..5eabb1250795c5515847ee5408de6a96abae2133 100644 (file)
@@ -122,10 +122,13 @@ public class ZipFile implements ZipConstants
   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);