Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8173072

zipfs fails to handle incorrect info-zip "extended timestamp extra field"

    XMLWordPrintable

Details

    Backports

      Description

        zipfs implementation throws ArrayIndexOutOfBoundsException when handles incorrect "extended timestamp extra field". (wlclient.jar)

        The offending zip file has a "extended timestamp extra field" that has sz 5 and flag 3. Info-zip spec defines the "flags" bits as

        --------------------------------------
                 The lower three bits of Flags in both headers indicate which time-
                  stamps are present in the LOCAL extra field:

                        bit 0 if set, modification time is present
        bit 1 if set, access time is present
        bit 2 if set, creation time is present
                        bits 3-7 reserved for additional timestamps; not set
        --------------------------------------

        which means when the flag is set to 3, it should contains both mtime and crime, with data size as 9 ( 1 byte flag + 4 bytes mtime + 4 bytes atime).

        The ZipEntry handles this situation better by checking both flags and the data length as

                           if ((flag & 0x1) != 0 && (sz0 + 4) <= sz) {
                                mtime = unixTimeToFileTime(get32S(extra, off + sz0));
                                sz0 += 4;
                            }
                            if ((flag & 0x2) != 0 && (sz0 + 4) <= sz) {
                                atime = unixTimeToFileTime(get32S(extra, off + sz0));
                                sz0 += 4;
                            }
                            if ((flag & 0x4) != 0 && (sz0 + 4) <= sz) {
                                ctime = unixTimeToFileTime(get32S(extra, off + sz0));
                                sz0 += 4;
                            }

        in which it skips trying to blindly read data does not exist.

        ZipFileSystem implementation should do the same thing.

        Attachments

          Issue Links

            Activity

              People

                sherman Xueming Shen
                sherman Xueming Shen
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: