pax: truncate times to MAX_TIME_T, not INT_MAX
authormillert <millert@openbsd.org>
Mon, 26 Jun 2023 18:00:59 +0000 (18:00 +0000)
committermillert <millert@openbsd.org>
Mon, 26 Jun 2023 18:00:59 +0000 (18:00 +0000)
If the mtime in the file header is larger than MAX_TIME_T, trucate
it to MAX_TIME_T, not INT_MAX.  OK otto@

bin/pax/cpio.c
bin/pax/tar.c

index 92fe965..be0316d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cpio.c,v 1.33 2017/09/16 07:42:34 otto Exp $  */
+/*     $OpenBSD: cpio.c,v 1.34 2023/06/26 18:00:59 millert Exp $       */
 /*     $NetBSD: cpio.c,v 1.5 1995/03/21 09:07:13 cgd Exp $     */
 
 /*-
@@ -294,7 +294,7 @@ cpio_rd(ARCHD *arcn, char *buf)
        arcn->sb.st_rdev = (dev_t)asc_ul(hd->c_rdev, sizeof(hd->c_rdev), OCT);
        val = asc_ull(hd->c_mtime, sizeof(hd->c_mtime), OCT);
        if (val > MAX_TIME_T)
-               arcn->sb.st_mtime = INT_MAX;                    /* XXX 2038 */
+               arcn->sb.st_mtime = MAX_TIME_T;
        else
                arcn->sb.st_mtime = val;
        arcn->sb.st_mtim.tv_nsec = 0;
index 686ec52..b47c96b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: tar.c,v 1.70 2022/03/01 21:19:11 sthen Exp $  */
+/*     $OpenBSD: tar.c,v 1.71 2023/06/26 18:00:59 millert Exp $        */
 /*     $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $      */
 
 /*-
@@ -411,7 +411,7 @@ tar_rd(ARCHD *arcn, char *buf)
        arcn->sb.st_size = (off_t)asc_ull(hd->size, sizeof(hd->size), OCT);
        val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
        if (val > MAX_TIME_T)
-               arcn->sb.st_mtime = INT_MAX;                    /* XXX 2038 */
+               arcn->sb.st_mtime = MAX_TIME_T;
        else
                arcn->sb.st_mtime = val;
        arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
@@ -788,7 +788,7 @@ reset:
        if (arcn->sb.st_mtime == 0) {
                val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
                if (val > MAX_TIME_T)
-                       arcn->sb.st_mtime = INT_MAX;            /* XXX 2038 */
+                       arcn->sb.st_mtime = MAX_TIME_T;
                else
                        arcn->sb.st_mtime = val;
        }