diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-04-17 20:17:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-04-17 20:17:34 +0000 |
commit | 2a5d60ca8d5eb8094e4b2c008b3eb63b8a4c40d7 (patch) | |
tree | 79c24139ea807ed1dcbd919dbe8b6eb93293ff6d | |
parent | 14795d9b5911a39cebdc613a27d0d20c34503401 (diff) |
Handle greater time_t, so that .a files work after 2038.
ok miod
-rw-r--r-- | usr.bin/ar/archive.c | 9 | ||||
-rw-r--r-- | usr.bin/ar/archive.h | 8 | ||||
-rw-r--r-- | usr.bin/ranlib/build.c | 4 |
3 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/ar/archive.c b/usr.bin/ar/archive.c index d384a51996b..b56f7c45b9c 100644 --- a/usr.bin/ar/archive.c +++ b/usr.bin/ar/archive.c @@ -1,4 +1,4 @@ -/* $OpenBSD: archive.c,v 1.12 2009/12/13 18:13:28 sobrado Exp $ */ +/* $OpenBSD: archive.c,v 1.13 2013/04/17 20:17:32 deraadt Exp $ */ /* $NetBSD: archive.c,v 1.7 1995/03/26 03:27:46 glass Exp $ */ /*- @@ -142,6 +142,7 @@ get_arobj(int fd) #define DECIMAL 10 #define OCTAL 8 + /* XXX ar_date 2038 */ AR_ATOI(hdr->ar_date, chdr.date, sizeof(hdr->ar_date), DECIMAL); AR_ATOI(hdr->ar_uid, chdr.uid, sizeof(hdr->ar_uid), DECIMAL); AR_ATOI(hdr->ar_gid, chdr.gid, sizeof(hdr->ar_gid), DECIMAL); @@ -230,18 +231,18 @@ put_arobj(CF *cfp, struct stat *sb) (void)fflush(stderr); } (void)snprintf(hb, sizeof hb, - HDR3, name, (long int)sb->st_mtimespec.tv_sec, + HDR3, name, (long long)sb->st_mtimespec.tv_sec, uid, gid, sb->st_mode, sb->st_size, ARFMAG); lname = 0; } else if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) (void)snprintf(hb, sizeof hb, HDR1, AR_EFMT1, lname, - (long int)sb->st_mtimespec.tv_sec, + (long long)sb->st_mtimespec.tv_sec, uid, gid, sb->st_mode, sb->st_size + lname, ARFMAG); else { lname = 0; (void)snprintf(hb, sizeof hb, - HDR2, name, (long int)sb->st_mtimespec.tv_sec, + HDR2, name, (long long)sb->st_mtimespec.tv_sec, uid, gid, sb->st_mode, sb->st_size, ARFMAG); } size = sb->st_size; diff --git a/usr.bin/ar/archive.h b/usr.bin/ar/archive.h index b2f7b331896..233f98348d5 100644 --- a/usr.bin/ar/archive.h +++ b/usr.bin/ar/archive.h @@ -1,4 +1,4 @@ -/* $OpenBSD: archive.h,v 1.6 2012/12/05 23:20:24 deraadt Exp $ */ +/* $OpenBSD: archive.h,v 1.7 2013/04/17 20:17:32 deraadt Exp $ */ /* $NetBSD: archive.h,v 1.6 1995/03/25 06:39:43 glass Exp $ */ /*- @@ -86,11 +86,11 @@ typedef struct { } CHDR; /* Header format strings. */ -#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10qd%2s" -#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10qd%2s" +#define HDR1 "%s%-13d%-12lld%-6u%-6u%-8o%-10qd%2s" +#define HDR2 "%-16.16s%-12lld%-6u%-6u%-8o%-10qd%2s" #define OLDARMAXNAME 15 -#define HDR3 "%-16.15s%-12ld%-6u%-6u%-8o%-10qd%2s" +#define HDR3 "%-16.15s%-12lld%-6u%-6u%-8o%-10qd%2s" struct stat; diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c index 7572ac26dee..c88c7b807d3 100644 --- a/usr.bin/ranlib/build.c +++ b/usr.bin/ranlib/build.c @@ -1,4 +1,4 @@ -/* $OpenBSD: build.c,v 1.13 2009/10/27 23:59:42 deraadt Exp $ */ +/* $OpenBSD: build.c,v 1.14 2013/04/17 20:17:33 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -272,7 +272,7 @@ symobj(int mid) /* Put out the ranlib archive file header. */ #define DEFMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) - (void)snprintf(hb, sizeof hb, HDR2, RANLIBMAG, 0L, uid, gid, + (void)snprintf(hb, sizeof hb, HDR2, RANLIBMAG, (long long)0, uid, gid, DEFMODE & ~umask(0), (off_t)ransize, ARFMAG); if (!fwrite(hb, sizeof(struct ar_hdr), 1, fp)) error(tname); |