commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r922298 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/zip/
Date Fri, 12 Mar 2010 15:35:44 GMT
Author: bodewig
Date: Fri Mar 12 15:35:44 2010
New Revision: 922298

URL: http://svn.apache.org/viewvc?rev=922298&view=rev
Log:
Check a data descriptor actually uses the signature before skipping too many bytes if it doesn't.
 COMPRESS-101

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=922298&r1=922297&r2=922298&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Mar 12 15:35:44 2010
@@ -23,6 +23,10 @@
   </properties>
   <body>
     <release version="1.1" date="as in SVN" description="Release 1.1">
+      <action type="fix" date="2010-03-12" issue="COMPRESS-101">
+        ZipArchiveInputStream should now properly read archives that
+        use data descriptors but without the "unofficial" signature.
+      </action>
       <action type="add" date="2010-03-09" issue="COMPRESS-98">
         The ZIP classes will throw specialized exceptions if any
         attempt is made to read or write data that uses zip features

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=922298&r1=922297&r2=922298&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Fri Mar 12 15:35:44 2010
@@ -373,7 +373,15 @@ public class ZipArchiveInputStream exten
         }
 
         if (hasDataDescriptor) {
-            readFully(new byte[4 * WORD]);
+            byte[] sig = new byte[WORD];
+            readFully(sig);
+            if (ZipLong.DD_SIG.equals(new ZipLong(sig))) {
+                readFully(new byte[3 * WORD]);
+            } else {
+                // data descriptor without signature, we've already
+                // read the CRC
+                readFully(new byte[2 * WORD]);
+            }
         }
 
         inf.reset();

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=922298&r1=922297&r2=922298&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Fri Mar 12 15:35:44 2010
@@ -597,7 +597,7 @@ public class ZipArchiveOutputStream exte
     /**
      * data descriptor signature
      */
-    static final byte[] DD_SIG = ZipLong.getBytes(0X08074B50L);
+    static final byte[] DD_SIG = ZipLong.DD_SIG.getBytes();
     /**
      * central file header signature
      */

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java?rev=922298&r1=922297&r2=922298&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
Fri Mar 12 15:35:44 2010
@@ -49,6 +49,12 @@ public final class ZipLong implements Cl
     public static final ZipLong LFH_SIG = new ZipLong(0X04034B50L);
 
     /**
+     * Data Descriptor signature
+     * @since Commons Compress 1.1
+     */
+    public static final ZipLong DD_SIG = new ZipLong(0X08074B50L);
+
+    /**
      * Create instance from a number.
      * @param value the long to store as a ZipLong
      */



Mime
View raw message