commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1439116 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Date Sun, 27 Jan 2013 16:39:36 GMT
Author: bodewig
Date: Sun Jan 27 16:39:36 2013
New Revision: 1439116

URL: http://svn.apache.org/viewvc?rev=1439116&view=rev
Log:
don't search beyond the start of the archive

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
  (contents, props changed)

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1439116&r1=1439115&r2=1439116&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Sun Jan 27 16:39:36 2013
@@ -667,13 +667,20 @@ public class ZipFile {
     private void positionAtCentralDirectory()
         throws IOException {
         positionAtEndOfCentralDirectoryRecord();
-        archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH);
-        archive.readFully(WORD_BUF);
-        boolean found = Arrays.equals(ZipArchiveOutputStream.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(ZipArchiveOutputStream.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();

Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
------------------------------------------------------------------------------
  Merged /ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:r1439115



Mime
View raw message