Hi,

Please help review the changes for JDK-8135108

issue: https://bugs.openjdk.java.net/browse/JDK-8135108
webrev: http://cr.openjdk.java.net/~sherman/8135108

It's a overflow of the low 32-bit of xdostime when the year is > 0x70
(which will be shifting << 25). We have a similar patch at
ZipUtils.javaToDosTime(). Obviously ZipEntry.setTimeLocale() needs
one as well.

   /**
     * Converts Java time to DOS time.
     */
    private static long javaToDosTime(long time) {
        Instant instant = Instant.ofEpochMilli(time);
        LocalDateTime ldt = LocalDateTime.ofInstant(
                instant, ZoneId.systemDefault());
        int year = ldt.getYear() - 1980;
        if (year < 0) {
            return (1 << 21) | (1 << 16);
        }
        return (year << 25 |
            ldt.getMonthValue() << 21 |
            ldt.getDayOfMonth() << 16 |
            ldt.getHour() << 11 |
            ldt.getMinute() << 5 |
            ldt.getSecond() >> 1) & 0xffffffffL;
    }

Thanks!
Sherman

Reply via email to