I tried to make unzip Y2038 compliant by -DTIME_T_TYPE_DOUBLE on 32bit, but the code didi not compile.
Below is the fix.
With this patch, zipfile composed on x86_64 was properly unzipped on 32bit unzip.
From: <kabe@>
Subject: Make it compile with -DTIME_T_TYPE_DOUBLE
diff -up ./process.c.t64 ./process.c
--- ./process.c.t64 2025-08-09 17:43:34.238185944 +0900
+++ ./process.c 2025-08-09 17:45:30.942845653 +0900
@@ -2854,7 +2854,7 @@ unsigned ef_scan_for_izux(ef_buf, ef_len
i_time));
#ifdef TIME_T_TYPE_DOUBLE
if ((ulg)(i_time) & (ulg)(0x80000000L)) {
- if (ut_in_archive_sgn == -1)
+ if (ut_in_archive_sgn == -1) {
z_utim->atime =
(time_t)((long)i_time | (~(long)0x7fffffffL));
} else if (ut_in_archive_sgn == 1) {
@@ -2884,13 +2884,14 @@ unsigned ef_scan_for_izux(ef_buf, ef_len
}
}
if (flags & EB_UT_FL_CTIME) {
+ unsigned eb_idx = EB_UT_TIME1;
if ((eb_idx+4) <= eb_len) {
i_time = (long)makelong((EB_HEADSIZE+eb_idx) + ef_buf);
TTrace((stderr," UT e.f. creation time = %ld\n",
i_time));
#ifdef TIME_T_TYPE_DOUBLE
if ((ulg)(i_time) & (ulg)(0x80000000L)) {
- if (ut_in_archive_sgn == -1)
+ if (ut_in_archive_sgn == -1) {
z_utim->ctime =
(time_t)((long)i_time | (~(long)0x7fffffffL));
} else if (ut_in_archive_sgn == 1) {
@@ -3037,7 +3038,7 @@ unsigned ef_scan_for_izux(ef_buf, ef_len
TTrace((stderr," Unix EF actime = %ld\n", i_time));
#ifdef TIME_T_TYPE_DOUBLE
if ((ulg)(i_time) & (ulg)(0x80000000L)) {
- if (ut_in_archive_sgn == -1)
+ if (ut_in_archive_sgn == -1) {
z_utim->atime =
(time_t)((long)i_time | (~(long)0x7fffffffL));
} else if (ut_in_archive_sgn == 1) {
Thanks for taking the time to provide a patch for
TIME_T_TYPE_DOUBLE
.Confirmed that building the unzip 6.0 source with
-DTIME_T_TYPE_DOUBLE
does trigger a number of compilation issues.Although your patch does silence them, I see that the updates to the development source for unzip appear to have a fix for this issue -- it builds with any compilation errors. . With a very superficial look at the sources, I suspect your's my be the correct change. Won't know for sure until I run a few tests.
One thing I notice is that the patch needs fuzz to make it apply. What version of unzip sources did you apply this change to and where did you get it?
Out of interest, are you encountering an issue that means you need this fix right now?