Browse Source

fail early if ZipFile is applied to a non-ZIP archive. PR 45463. Suggested by Alison Winters.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@683942 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
9b4b922d2c
4 changed files with 14 additions and 1 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +5
    -1
      src/main/org/apache/tools/zip/ZipFile.java

+ 1
- 0
CONTRIBUTORS View File

@@ -4,6 +4,7 @@ Adam Blinkinsop
Aleksandr Ishutin
Alexey Panchenko
Alexey Solofnenko
Alison Winters
Andreas Ames
Andreas Mross
Andrew Everitt


+ 4
- 0
WHATSNEW View File

@@ -235,6 +235,10 @@ Other changes:
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
=============================================



+ 4
- 0
contributors.xml View File

@@ -46,6 +46,10 @@
<first>Alexey</first>
<last>Solofnenko</last>
</name>
<name>
<first>Alison</first>
<last>Winters</last>
</name>
<name>
<first>Andreas</first>
<last>Ames</last>


+ 5
- 1
src/main/org/apache/tools/zip/ZipFile.java View File

@@ -366,6 +366,9 @@ public class ZipFile {
/* 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 @@ public class ZipFile {
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]) {


Loading…
Cancel
Save