src/java.base/share/classes/java/util/zip/ZipFile.java
changeset 47223 723486922bfe
parent 47216 71c04702a3d5
child 47987 85ea7e83af30
equal deleted inserted replaced
47222:c8ac05bbe477 47223:723486922bfe
  1120                             comment = new byte[comlen];
  1120                             comment = new byte[comlen];
  1121                             if (readFullyAt(comment, 0, comlen, end.endpos + ENDHDR) != comlen) {
  1121                             if (readFullyAt(comment, 0, comlen, end.endpos + ENDHDR) != comlen) {
  1122                                 zerror("zip comment read failed");
  1122                                 zerror("zip comment read failed");
  1123                             }
  1123                             }
  1124                         }
  1124                         }
  1125                         if (end.cenlen == ZIP64_MAGICVAL ||
  1125                         // must check for a zip64 end record; it is always permitted to be present
  1126                             end.cenoff == ZIP64_MAGICVAL ||
  1126                         try {
  1127                             end.centot == ZIP64_MAGICCOUNT)
  1127                             byte[] loc64 = new byte[ZIP64_LOCHDR];
  1128                         {
  1128                             if (end.endpos < ZIP64_LOCHDR ||
  1129                             // need to find the zip64 end;
  1129                                 readFullyAt(loc64, 0, loc64.length, end.endpos - ZIP64_LOCHDR)
  1130                             try {
  1130                                 != loc64.length || GETSIG(loc64) != ZIP64_LOCSIG) {
  1131                                 byte[] loc64 = new byte[ZIP64_LOCHDR];
  1131                                 return end;
  1132                                 if (readFullyAt(loc64, 0, loc64.length, end.endpos - ZIP64_LOCHDR)
  1132                             }
  1133                                     != loc64.length || GETSIG(loc64) != ZIP64_LOCSIG) {
  1133                             long end64pos = ZIP64_LOCOFF(loc64);
  1134                                     return end;
  1134                             byte[] end64buf = new byte[ZIP64_ENDHDR];
  1135                                 }
  1135                             if (readFullyAt(end64buf, 0, end64buf.length, end64pos)
  1136                                 long end64pos = ZIP64_LOCOFF(loc64);
  1136                                 != end64buf.length || GETSIG(end64buf) != ZIP64_ENDSIG) {
  1137                                 byte[] end64buf = new byte[ZIP64_ENDHDR];
  1137                                 return end;
  1138                                 if (readFullyAt(end64buf, 0, end64buf.length, end64pos)
  1138                             }
  1139                                     != end64buf.length || GETSIG(end64buf) != ZIP64_ENDSIG) {
  1139                             // end64 candidate found,
  1140                                     return end;
  1140                             long cenlen64 = ZIP64_ENDSIZ(end64buf);
  1141                                 }
  1141                             long cenoff64 = ZIP64_ENDOFF(end64buf);
  1142                                 // end64 found, re-calcualte everything.
  1142                             long centot64 = ZIP64_ENDTOT(end64buf);
  1143                                 end.cenlen = ZIP64_ENDSIZ(end64buf);
  1143                             // double-check
  1144                                 end.cenoff = ZIP64_ENDOFF(end64buf);
  1144                             if (cenlen64 != end.cenlen && end.cenlen != ZIP64_MAGICVAL ||
  1145                                 end.centot = (int)ZIP64_ENDTOT(end64buf); // assume total < 2g
  1145                                 cenoff64 != end.cenoff && end.cenoff != ZIP64_MAGICVAL ||
  1146                                 end.endpos = end64pos;
  1146                                 centot64 != end.centot && end.centot != ZIP64_MAGICCOUNT) {
  1147                             } catch (IOException x) {}    // no zip64 loc/end
  1147                                 return end;
  1148                         }
  1148                             }
       
  1149                             // to use the end64 values
       
  1150                             end.cenlen = cenlen64;
       
  1151                             end.cenoff = cenoff64;
       
  1152                             end.centot = (int)centot64; // assume total < 2g
       
  1153                             end.endpos = end64pos;
       
  1154                         } catch (IOException x) {}    // no zip64 loc/end
  1149                         return end;
  1155                         return end;
  1150                     }
  1156                     }
  1151                 }
  1157                 }
  1152             }
  1158             }
  1153             zerror("zip END header not found");
  1159             zerror("zip END header not found");