This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
ZipFile patch for PR 25
- To: java-patches at sourceware dot cygnus dot com
- Subject: ZipFile patch for PR 25
- From: Anthony Green <green at cygnus dot com>
- Date: Sun, 7 Nov 1999 00:29:13 -0800 (PST)
I'm about to commit this fix to PR 25. It computes data offsets
correctly for ZipEntry objects.
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);
AG
--
Anthony Green Cygnus Solutions
Sunnyvale, California