Author: bodewig
Date: Fri Aug 8 04:36:43 2008
New Revision: 683942
URL: http://svn.apache.org/viewvc?rev=683942&view=rev
Log:
fail early if ZipFile is applied to a non-ZIP archive. PR 45463. Suggested by
Alison Winters.
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=683942&r1=683941&r2=683942&view=diff
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=683942&r1=683941&r2=683942&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Aug 8 04:36:43 2008
@@ -235,6 +235,10 @@
relative file name).
Bugzilla Report 28911.
+ * <unzip> will now detect that it was asked to extract a file that is
+ not an archive earlier if the file is big.
+ Bugzilla Report 45463.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=683942&r1=683941&r2=683942&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Fri Aug 8 04:36:43 2008
@@ -47,6 +47,10 @@
<last>Solofnenko</last>
</name>
<name>
+ <first>Alison</first>
+ <last>Winters</last>
+ </name>
+ <name>
<first>Andreas</first>
<last>Ames</last>
</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=683942&r1=683941&r2=683942&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 Fri Aug 8
04:36:43 2008
@@ -366,6 +366,9 @@
/* the starting disk number */ + WORD
/* zipfile comment length */ + SHORT;
+ private static final int MAX_EOCD_SIZE = MIN_EOCD_SIZE
+ /* maximum length of zipfile comment */ + 0xFFFF;
+
private static final int CFD_LOCATOR_OFFSET =
/* end of central dir signature */ WORD
/* number of this disk */ + SHORT
@@ -386,11 +389,12 @@
throws IOException {
boolean found = false;
long off = archive.length() - MIN_EOCD_SIZE;
+ long stopSearching = Math.max(0L, archive.length() - MAX_EOCD_SIZE);
if (off >= 0) {
archive.seek(off);
byte[] sig = ZipOutputStream.EOCD_SIG;
int curr = archive.read();
- while (curr != -1) {
+ while (off >= stopSearching && curr != -1) {
if (curr == sig[POS_0]) {
curr = archive.read();
if (curr == sig[POS_1]) {