From 82641d77bb4d421ae6190f0b99484f668ebc2106 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Sun, 27 Jan 2013 16:36:52 +0000 Subject: [PATCH] don't search beyond the start of the archive git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1439115 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/zip/ZipFile.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/zip/ZipFile.java b/src/main/org/apache/tools/zip/ZipFile.java index 0f09d0fd2..393fff4ca 100644 --- a/src/main/org/apache/tools/zip/ZipFile.java +++ b/src/main/org/apache/tools/zip/ZipFile.java @@ -667,13 +667,19 @@ public class ZipFile { private void positionAtCentralDirectory() throws IOException { positionAtEndOfCentralDirectoryRecord(); - archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH); - archive.readFully(WORD_BUF); - boolean found = Arrays.equals(ZipOutputStream.ZIP64_EOCD_LOC_SIG, - WORD_BUF); + boolean found = false; + boolean searchedForZip64EOCD = + archive.getFilePointer() > ZIP64_EOCDL_LENGTH; + if (searchedForZip64EOCD) { + archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH); + archive.readFully(WORD_BUF); + found = Arrays.equals(ZipOutputStream.ZIP64_EOCD_LOC_SIG, WORD_BUF); + } if (!found) { // not a ZIP64 archive - skipBytes(ZIP64_EOCDL_LENGTH - WORD); + if (searchedForZip64EOCD) { + skipBytes(ZIP64_EOCDL_LENGTH - WORD); + } positionAtCentralDirectory32(); } else { positionAtCentralDirectory64();