src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java

changeset 1467
189b26e3818f
parent 1442
fcf89720ae71
child 2525
2eb010b6cb22
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Fri Dec 21 08:45:43 2012 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Fri Dec 21 15:27:55 2012 +0000
     1.3 @@ -548,17 +548,15 @@
     1.4                  }
     1.5  
     1.6                  if (i >= 0) {
     1.7 -                    zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12) + 2];
     1.8 -                    zipDir[0] = endbuf[i + 10];
     1.9 -                    zipDir[1] = endbuf[i + 11];
    1.10 +                    zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12)];
    1.11                      int sz = get4ByteLittleEndian(endbuf, i + 16);
    1.12                      // a negative offset or the entries field indicates a
    1.13                      // potential zip64 archive
    1.14 -                    if (sz < 0 || get2ByteLittleEndian(zipDir, 0) == 0xffff) {
    1.15 +                    if (sz < 0 || get2ByteLittleEndian(endbuf, i + 10) == 0xffff) {
    1.16                          throw new ZipFormatException("detected a zip64 archive");
    1.17                      }
    1.18                      zipRandomFile.seek(start + sz);
    1.19 -                    zipRandomFile.readFully(zipDir, 2, zipDir.length - 2);
    1.20 +                    zipRandomFile.readFully(zipDir, 0, zipDir.length);
    1.21                      return;
    1.22                  } else {
    1.23                      endbufend = endbufpos + 21;
    1.24 @@ -568,14 +566,13 @@
    1.25          }
    1.26  
    1.27          private void buildIndex() throws IOException {
    1.28 -            int entryCount = get2ByteLittleEndian(zipDir, 0);
    1.29 +            int len = zipDir.length;
    1.30  
    1.31              // Add each of the files
    1.32 -            if (entryCount > 0) {
    1.33 +            if (len > 0) {
    1.34                  directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
    1.35                  ArrayList<Entry> entryList = new ArrayList<Entry>();
    1.36 -                int pos = 2;
    1.37 -                for (int i = 0; i < entryCount; i++) {
    1.38 +                for (int pos = 0; pos < len; ) {
    1.39                      pos = readEntry(pos, entryList, directories);
    1.40                  }
    1.41  

mercurial