Skip to content

Commit c76cd6a

Browse files
committed
check minimum timestamp: avoid negative Zip 5455 Extended Timestamp
1 parent d88dfdc commit c76cd6a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,14 @@ protected FileTime normalizeLastModifiedTime(FileTime lastModifiedTime) {
698698
*/
699699
private static long dosToJavaTime(long dosTime) {
700700
Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT);
701+
if (dosTime < MIN_DOS_JAVA_TIME) {
702+
dosTime = MIN_DOS_JAVA_TIME;
703+
}
701704
cal.setTimeInMillis(dosTime);
702705
return dosTime - (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET));
703706
}
707+
708+
// minimum DOS time that will give a positive Java time, whatever the current TZ is:
709+
// biggest TZ offset is for Etc/GMT-14 https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
710+
private static final long MIN_DOS_JAVA_TIME = 1000 * 14 * 3600;
704711
}

0 commit comments

Comments
 (0)