summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2017-09-12 17:11:12 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2017-09-12 17:11:12 +0000
commit6ba6d66c2f156d06e233b6847b2e38f0beda03c0 (patch)
tree773adb1bbb9ae316311529db24bc260b58486473
parentf5d45decb0600604d3346b899d65dfaffa97b2d3 (diff)
there is no offical way to get the max value of time_t, but this one works
on any sensible posix system (in which time_t must be an integer type) ok deraadt@ millert@
-rw-r--r--bin/pax/cpio.c4
-rw-r--r--bin/pax/extern.h4
-rw-r--r--bin/pax/pax.h4
-rw-r--r--bin/pax/tables.c4
-rw-r--r--bin/pax/tar.c6
5 files changed, 12 insertions, 10 deletions
diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c
index 9274d88809c..fa78ae2bf60 100644
--- a/bin/pax/cpio.c
+++ b/bin/pax/cpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpio.c,v 1.31 2017/09/06 17:24:22 otto Exp $ */
+/* $OpenBSD: cpio.c,v 1.32 2017/09/12 17:11:11 otto Exp $ */
/* $NetBSD: cpio.c,v 1.5 1995/03/21 09:07:13 cgd Exp $ */
/*-
@@ -293,7 +293,7 @@ cpio_rd(ARCHD *arcn, char *buf)
OCT);
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 ((time_t)val < 0 || (time_t)val != val)
+ if (val > MAX_TIME_T)
arcn->sb.st_mtime = INT_MAX; /* XXX 2038 */
else
arcn->sb.st_mtime = val;
diff --git a/bin/pax/extern.h b/bin/pax/extern.h
index 1207d79ff85..5bc00d0761b 100644
--- a/bin/pax/extern.h
+++ b/bin/pax/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.57 2016/08/25 01:44:55 guenther Exp $ */
+/* $OpenBSD: extern.h,v 1.58 2017/09/12 17:11:11 otto Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
@@ -268,7 +268,7 @@ int sltab_add_link(const char *, const struct stat *);
void sltab_process(int _in_sig);
int name_start(void);
int add_name(char *, int, char *);
-void sub_name(char *, int *, size_t);
+void sub_name(char *, int *, int);
#ifndef NOCPIO
int dev_start(void);
int add_dev(ARCHD *);
diff --git a/bin/pax/pax.h b/bin/pax/pax.h
index b2c15a1e7f6..65d445a74db 100644
--- a/bin/pax/pax.h
+++ b/bin/pax/pax.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pax.h,v 1.28 2015/11/17 19:01:34 mmcc Exp $ */
+/* $OpenBSD: pax.h,v 1.29 2017/09/12 17:11:11 otto Exp $ */
/* $NetBSD: pax.h,v 1.3 1995/03/21 09:07:41 cgd Exp $ */
/*-
@@ -258,3 +258,5 @@ typedef struct oplist {
#define OCT 8
#define _PAX_ 1
#define _TFILE_BASE "paxXXXXXXXXXX"
+#define MAX_TIME_T (sizeof(time_t) == sizeof(long long) ? \
+ LLONG_MAX : INT_MAX)
diff --git a/bin/pax/tables.c b/bin/pax/tables.c
index b700f16499f..5f39610c84a 100644
--- a/bin/pax/tables.c
+++ b/bin/pax/tables.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tables.c,v 1.51 2017/03/16 03:53:37 deraadt Exp $ */
+/* $OpenBSD: tables.c,v 1.52 2017/09/12 17:11:11 otto Exp $ */
/* $NetBSD: tables.c,v 1.4 1995/03/21 09:07:45 cgd Exp $ */
/*-
@@ -1036,7 +1036,7 @@ add_name(char *oname, int onamelen, char *nname)
*/
void
-sub_name(char *oname, int *onamelen, size_t onamesize)
+sub_name(char *oname, int *onamelen, int onamesize)
{
NAMT *pt;
u_int indx;
diff --git a/bin/pax/tar.c b/bin/pax/tar.c
index 9508b95800a..88ca076f96f 100644
--- a/bin/pax/tar.c
+++ b/bin/pax/tar.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tar.c,v 1.64 2017/09/08 12:23:47 otto Exp $ */
+/* $OpenBSD: tar.c,v 1.65 2017/09/12 17:11:11 otto Exp $ */
/* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */
/*-
@@ -410,7 +410,7 @@ tar_rd(ARCHD *arcn, char *buf)
arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT);
arcn->sb.st_size = (off_t)asc_ull(hd->size, sizeof(hd->size), OCT);
val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
- if ((time_t)val < 0 || (time_t)val != val)
+ if (val > MAX_TIME_T)
arcn->sb.st_mtime = INT_MAX; /* XXX 2038 */
else
arcn->sb.st_mtime = val;
@@ -800,7 +800,7 @@ reset:
0xfff);
arcn->sb.st_size = (off_t)asc_ull(hd->size, sizeof(hd->size), OCT);
val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
- if ((time_t)val < 0 || (time_t)val != val)
+ if (val > MAX_TIME_T)
arcn->sb.st_mtime = INT_MAX; /* XXX 2038 */
else
arcn->sb.st_mtime = val;