Browse Source

don't search beyond the start of the archive

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1439115 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 12 years ago
parent
commit
82641d77bb
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      src/main/org/apache/tools/zip/ZipFile.java

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

@@ -667,13 +667,19 @@ public class ZipFile {
private void positionAtCentralDirectory()
throws IOException {
positionAtEndOfCentralDirectoryRecord();
archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH);
archive.readFully(WORD_BUF);
boolean found = Arrays.equals(ZipOutputStream.ZIP64_EOCD_LOC_SIG,
WORD_BUF);
boolean found = false;
boolean searchedForZip64EOCD =
archive.getFilePointer() > ZIP64_EOCDL_LENGTH;
if (searchedForZip64EOCD) {
archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH);
archive.readFully(WORD_BUF);
found = Arrays.equals(ZipOutputStream.ZIP64_EOCD_LOC_SIG, WORD_BUF);
}
if (!found) {
// not a ZIP64 archive
skipBytes(ZIP64_EOCDL_LENGTH - WORD);
if (searchedForZip64EOCD) {
skipBytes(ZIP64_EOCDL_LENGTH - WORD);
}
positionAtCentralDirectory32();
} else {
positionAtCentralDirectory64();


Loading…
Cancel
Save