src/java.base/share/classes/java/util/zip/ZipEntry.java

Print this page




 464                 int sz = get16(extra, off + 2);
 465                 off += 4;
 466                 if (off + sz > len)         // invalid data
 467                     break;
 468                 switch (tag) {
 469                 case EXTID_ZIP64:
 470                     if (doZIP64) {
 471                         // LOC extra zip64 entry MUST include BOTH original
 472                         // and compressed file size fields.
 473                         // If invalid zip64 extra fields, simply skip. Even
 474                         // it's rare, it's possible the entry size happens to
 475                         // be the magic value and it "accidently" has some
 476                         // bytes in extra match the id.
 477                         if (sz >= 16) {
 478                             size = get64(extra, off);
 479                             csize = get64(extra, off + 8);
 480                         }
 481                     }
 482                     break;
 483                 case EXTID_NTFS:


 484                     int pos = off + 4;               // reserved 4 bytes
 485                     if (get16(extra, pos) !=  0x0001 || get16(extra, pos + 2) != 24)
 486                         break;
 487                     mtime = winTimeToFileTime(get64(extra, pos + 4));
 488                     atime = winTimeToFileTime(get64(extra, pos + 12));
 489                     ctime = winTimeToFileTime(get64(extra, pos + 20));
 490                     break;
 491                 case EXTID_EXTT:
 492                     int flag = Byte.toUnsignedInt(extra[off]);
 493                     int sz0 = 1;
 494                     // The CEN-header extra field contains the modification
 495                     // time only, or no timestamp at all. 'sz' is used to
 496                     // flag its presence or absence. But if mtime is present
 497                     // in LOC it must be present in CEN as well.
 498                     if ((flag & 0x1) != 0 && (sz0 + 4) <= sz) {
 499                         mtime = unixTimeToFileTime(get32(extra, off + sz0));
 500                         sz0 += 4;
 501                     }
 502                     if ((flag & 0x2) != 0 && (sz0 + 4) <= sz) {
 503                         atime = unixTimeToFileTime(get32(extra, off + sz0));




 464                 int sz = get16(extra, off + 2);
 465                 off += 4;
 466                 if (off + sz > len)         // invalid data
 467                     break;
 468                 switch (tag) {
 469                 case EXTID_ZIP64:
 470                     if (doZIP64) {
 471                         // LOC extra zip64 entry MUST include BOTH original
 472                         // and compressed file size fields.
 473                         // If invalid zip64 extra fields, simply skip. Even
 474                         // it's rare, it's possible the entry size happens to
 475                         // be the magic value and it "accidently" has some
 476                         // bytes in extra match the id.
 477                         if (sz >= 16) {
 478                             size = get64(extra, off);
 479                             csize = get64(extra, off + 8);
 480                         }
 481                     }
 482                     break;
 483                 case EXTID_NTFS:
 484                     if (sz < 32) // reserved  4 bytes + tag 2 bytes + size 2 bytes
 485                         break;   // m[a|c]time 24 bytes
 486                     int pos = off + 4;               // reserved 4 bytes
 487                     if (get16(extra, pos) !=  0x0001 || get16(extra, pos + 2) != 24)
 488                         break;
 489                     mtime = winTimeToFileTime(get64(extra, pos + 4));
 490                     atime = winTimeToFileTime(get64(extra, pos + 12));
 491                     ctime = winTimeToFileTime(get64(extra, pos + 20));
 492                     break;
 493                 case EXTID_EXTT:
 494                     int flag = Byte.toUnsignedInt(extra[off]);
 495                     int sz0 = 1;
 496                     // The CEN-header extra field contains the modification
 497                     // time only, or no timestamp at all. 'sz' is used to
 498                     // flag its presence or absence. But if mtime is present
 499                     // in LOC it must be present in CEN as well.
 500                     if ((flag & 0x1) != 0 && (sz0 + 4) <= sz) {
 501                         mtime = unixTimeToFileTime(get32(extra, off + sz0));
 502                         sz0 += 4;
 503                     }
 504                     if ((flag & 0x2) != 0 && (sz0 + 4) <= sz) {
 505                         atime = unixTimeToFileTime(get32(extra, off + sz0));