ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r739300 - in /ant/core/trunk: ./ src/main/org/apache/tools/zip/ src/tests/antunit/taskdefs/ src/tests/antunit/taskdefs/zip/ src/tests/junit/org/apache/tools/zip/
Date Fri, 30 Jan 2009 15:00:23 GMT
Author: bodewig
Date: Fri Jan 30 15:00:21 2009
New Revision: 739300

URL: http://svn.apache.org/viewvc?rev=739300&view=rev
Log:
Ignore ZIP extra fields that don't contain the recommended header+length structure - this
is what unzip does as well.  PR 42940

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/zip/ExtraFieldUtils.java
    ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java
    ant/core/trunk/src/main/org/apache/tools/zip/ZipExtraField.java
    ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml
    ant/core/trunk/src/tests/antunit/taskdefs/zip/Bugzilla-46559.zip
    ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jan 30 15:00:21 2009
@@ -670,6 +670,10 @@
    processor.
    Bugzilla Issue 46612.
 
+ * the ZIP library will now ignore ZIP extra fields that don't specify
+   a size.
+   Bugzilla Report 42940.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/src/main/org/apache/tools/zip/ExtraFieldUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ExtraFieldUtils.java?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ExtraFieldUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ExtraFieldUtils.java Fri Jan 30 15:00:21
2009
@@ -117,10 +117,6 @@
             }
             start += (length + WORD);
         }
-        if (start != data.length) { // array not exhausted
-            throw new ZipException("data starting at " + start
-                + " is in unknown format");
-        }
 
         ZipExtraField[] result = new ZipExtraField[v.size()];
         return (ZipExtraField[]) v.toArray(result);

Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java Fri Jan 30 15:00:21 2009
@@ -252,7 +252,7 @@
         try {
             setExtraFields(ExtraFieldUtils.parse(extra));
         } catch (Exception e) {
-            throw new RuntimeException(e.getMessage());
+            throw new RuntimeException(e.getMessage(), e);
         }
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipExtraField.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipExtraField.java?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipExtraField.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipExtraField.java Fri Jan 30 15:00:21 2009
@@ -64,7 +64,7 @@
     byte[] getLocalFileDataData();
 
     /**
-     * The actual data to put central directory - without Header-ID or
+     * The actual data to put into central directory - without Header-ID or
      * length specifier.
      * @return the data
      * @since 1.1

Modified: ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml Fri Jan 30 15:00:21 2009
@@ -44,6 +44,16 @@
     <au:assertFileExists file="${output}/foo/file"/>
   </target>
 
+  <target name="testTwoByteExtraFieldInLFH"
+          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=42940"
+          >
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <copy file="zip/Bugzilla-42940.zip" tofile="${input}/test.zip"/>
+    <unzip src="${input}/test.zip" dest="${output}"/>
+    <au:assertFileExists file="${output}/META-INF/MANIFEST.MF"/>
+  </target>
+
   <target name="testArchiveIsClosedForInvalidZips"
           description="https://issues.apache.org/bugzilla/show_bug.cgi?id=46559"
           >

Modified: ant/core/trunk/src/tests/antunit/taskdefs/zip/Bugzilla-46559.zip
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/zip/Bugzilla-46559.zip?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java?rev=739300&r1=739299&r2=739300&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java Fri Jan 30
15:00:21 2009
@@ -40,7 +40,7 @@
         a.setDirectory(true);
         dummy = new UnrecognizedExtraField();
         dummy.setHeaderId(new ZipShort(1));
-        dummy.setLocalFileDataData(new byte[0]);
+        dummy.setLocalFileDataData(new byte[] {0});
         dummy.setCentralDirectoryData(new byte[] {0});
 
         aLocal = a.getLocalFileDataData();
@@ -68,7 +68,7 @@
         assertEquals("mode field 1", 040755,
                      ((AsiExtraField) ze[0]).getMode());
         assertTrue("type field 2", ze[1] instanceof UnrecognizedExtraField);
-        assertEquals("data length field 2", 0,
+        assertEquals("data length field 2", 1,
                      ze[1].getLocalFileDataLength().getValue());
 
         byte[] data2 = new byte[data.length-1];



Mime
View raw message