From 2f186deaaa04c90e3a8af7a92e56f2d01994d350 Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 26 Jun 2023 18:00:59 +0000 Subject: [PATCH] pax: truncate times to MAX_TIME_T, not INT_MAX 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 | 4 ++-- bin/pax/tar.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index 92fe965163a..be0316d8dd9 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -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; diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 686ec524f83..b47c96bf084 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -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; } -- 2.20.1