You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/07/17 15:14:31 UTC

svn commit: r677575 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml src/main/org/apache/tools/zip/ZipFile.java src/tests/antunit/taskdefs/broken_cd.zip src/tests/antunit/taskdefs/unzip-test.xml

Author: bodewig
Date: Thu Jul 17 06:14:30 2008
New Revision: 677575

URL: http://svn.apache.org/viewvc?rev=677575&view=rev
Log:
an archive with an empty central directory is broken.  PR 35000.  Submitted by Thomas Aglassinger.

Added:
    ant/core/trunk/src/tests/antunit/taskdefs/broken_cd.zip   (with props)
    ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml   (with props)
Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=677575&r1=677574&r2=677575&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=677575&r1=677574&r2=677575&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Jul 17 06:14:30 2008
@@ -58,6 +58,9 @@
    passed in a null or empty InputStream to read from.
    Bugzilla Report 32200
 
+ * <unzip> will now fail on archives with an empty central directory.
+   Bugzilla report 35000.
+
 Fixed bugs:
 -----------
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=677575&r1=677574&r2=677575&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Jul 17 06:14:30 2008
@@ -1076,6 +1076,10 @@
   </name>
   <name>
     <first>Thomas</first>
+    <last>Aglassinger</last>
+  </name>
+  <name>
+    <first>Thomas</first>
     <last>Butz</last>
   </name>
   <name>

Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java?rev=677575&r1=677574&r2=677575&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java Thu Jul 17 06:14:30 2008
@@ -276,6 +276,10 @@
         archive.readFully(signatureBytes);
         long sig = ZipLong.getValue(signatureBytes);
         final long cfhSig = ZipLong.getValue(ZipOutputStream.CFH_SIG);
+        if (sig != cfhSig) {
+            throw new IOException("central directory is empty, can't expand"
+                                  + " archive.");
+        }
         while (sig == cfhSig) {
             archive.readFully(cfh);
             int off = 0;

Added: ant/core/trunk/src/tests/antunit/taskdefs/broken_cd.zip
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/broken_cd.zip?rev=677575&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/core/trunk/src/tests/antunit/taskdefs/broken_cd.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 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=677575&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml Thu Jul 17 06:14:30 2008
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project name="unzip-test" default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit">
+  <import file="../antunit-base.xml" />
+
+  <property name="dest.dir" location="unzip.dest"/>
+
+  <target name="setUp">
+    <mkdir dir="${dest.dir}" />
+  </target>
+
+  <target name="tearDown">
+    <delete dir="${dest.dir}"/>
+  </target>
+
+  <target name="testFailureOnBrokenCentralDirectoryStructure">
+    <au:expectfailure
+       expectedmessage="central directory is empty, can't expand archive.">
+      <unzip src="broken_cd.zip" dest="${dest.dir}"/>
+    </au:expectfailure>
+  </target>
+</project>

Propchange: ant/core/trunk/src/tests/antunit/taskdefs/unzip-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native