From a21d0597666aa3c801f70ad24962543a97276ca9 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 7 Nov 1999 08:30:31 +0000 Subject: ZipFile.java: Compute the offset of the ZipEntry data correctly. * java/util/zip/ZipFile.java: Compute the offset of the ZipEntry data correctly. From-SVN: r30439 --- libjava/java/util/zip/ZipFile.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libjava/java') diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java index 1b0ebce..5eabb12 100644 --- a/libjava/java/util/zip/ZipFile.java +++ b/libjava/java/util/zip/ZipFile.java @@ -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); -- cgit v1.1