This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=bab898774c842a53144fe9b6debb10146aeb768a commit bab898774c842a53144fe9b6debb10146aeb768a Author: Guillem Jover <[email protected]> AuthorDate: Wed Sep 2 04:27:22 2020 +0200 dpkg-deb, dpkg-split: Fix time handling to support 64-bit time --- dpkg-deb/build.c | 13 +++++++------ dpkg-split/split.c | 9 +++++---- lib/dpkg/ar.c | 6 +++--- lib/dpkg/ar.h | 7 ++++--- lib/dpkg/pkg-format.c | 4 +++- lib/dpkg/t/c-tarextract.c | 2 +- lib/dpkg/tarfn.h | 2 +- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 7f29ba22f..c8b4f74a7 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -29,6 +29,7 @@ #include <errno.h> #include <limits.h> +#include <inttypes.h> #include <string.h> #include <time.h> #include <dirent.h> @@ -425,7 +426,7 @@ gen_dest_pathname_from_pkg(const char *dir, struct pkginfo *pkg) typedef void filenames_feed_func(const char *dir, int fd_out); struct tar_pack_options { - time_t timestamp; + intmax_t timestamp; const char *mode; bool root_owner_group; }; @@ -459,7 +460,7 @@ tarball_pack(const char *dir, filenames_feed_func *tar_filenames_feeder, if (chdir(dir)) ohshite(_("failed to chdir to '%.255s'"), dir); - snprintf(mtime, sizeof(mtime), "@%ld", options->timestamp); + snprintf(mtime, sizeof(mtime), "@%jd", options->timestamp); command_init(&cmd, TAR, "tar -cf"); command_add_args(&cmd, "tar", "-cf", "-", "--format=gnu", @@ -495,14 +496,14 @@ tarball_pack(const char *dir, filenames_feed_func *tar_filenames_feeder, subproc_reap(pid_tar, "tar -cf", 0); } -static time_t +static intmax_t parse_timestamp(const char *value) { - time_t timestamp; + intmax_t timestamp; char *end; errno = 0; - timestamp = strtol(value, &end, 10); + timestamp = strtoimax(value, &end, 10); if (value == end || *end || errno != 0) ohshite(_("unable to parse timestamp '%.255s'"), value); @@ -519,7 +520,7 @@ do_build(const char *const *argv) struct tar_pack_options tar_options; struct dpkg_error err; struct dpkg_ar *ar; - time_t timestamp; + intmax_t timestamp; const char *timestamp_str; const char *dir, *dest; char *ctrldir; diff --git a/dpkg-split/split.c b/dpkg-split/split.c index e197b22f2..607222365 100644 --- a/dpkg-split/split.c +++ b/dpkg-split/split.c @@ -28,6 +28,7 @@ #include <errno.h> #include <limits.h> +#include <inttypes.h> #include <fcntl.h> #include <libgen.h> #include <string.h> @@ -90,14 +91,14 @@ deb_parse_control(const char *filename) return pkg; } -static time_t +static intmax_t parse_timestamp(const char *value) { - time_t timestamp; + intmax_t timestamp; char *end; errno = 0; - timestamp = strtol(value, &end, 10); + timestamp = strtoimax(value, &end, 10); if (value == end || *end || errno != 0) ohshite(_("unable to parse timestamp '%.255s'"), value); @@ -132,7 +133,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize, struct dpkg_error err; int fd_src; struct stat st; - time_t timestamp; + intmax_t timestamp; const char *timestamp_str; const char *version; char hash[MD5HASHLEN + 1]; diff --git a/lib/dpkg/ar.c b/lib/dpkg/ar.c index 444b10cf7..57d304ce8 100644 --- a/lib/dpkg/ar.c +++ b/lib/dpkg/ar.c @@ -84,7 +84,7 @@ dpkg_ar_create(const char *filename, mode_t mode) } void -dpkg_ar_set_mtime(struct dpkg_ar *ar, time_t mtime) +dpkg_ar_set_mtime(struct dpkg_ar *ar, intmax_t mtime) { ar->time = mtime; } @@ -174,8 +174,8 @@ dpkg_ar_member_put_header(struct dpkg_ar *ar, struct dpkg_ar_member *member) ohshit(_("ar member size %jd too large"), (intmax_t)member->size); n = snprintf(header, sizeof(struct dpkg_ar_hdr) + 1, - "%-16s%-12lu%-6lu%-6lu%-8lo%-10jd`\n", - member->name, (unsigned long)member->time, + "%-16s%-12jd%-6lu%-6lu%-8lo%-10jd`\n", + member->name, (intmax_t)member->time, (unsigned long)member->uid, (unsigned long)member->gid, (unsigned long)member->mode, (intmax_t)member->size); if (n != sizeof(struct dpkg_ar_hdr)) diff --git a/lib/dpkg/ar.h b/lib/dpkg/ar.h index 55bfa6e99..680c13d2e 100644 --- a/lib/dpkg/ar.h +++ b/lib/dpkg/ar.h @@ -24,6 +24,7 @@ #include <sys/types.h> #include <stdbool.h> +#include <stdint.h> #include <ar.h> #include <dpkg/macros.h> @@ -57,7 +58,7 @@ struct dpkg_ar_hdr { struct dpkg_ar { const char *name; mode_t mode; - time_t time; + intmax_t time; off_t size; int fd; }; @@ -70,7 +71,7 @@ struct dpkg_ar_member { const char *name; off_t offset; off_t size; - time_t time; + intmax_t time; mode_t mode; uid_t uid; gid_t gid; @@ -80,7 +81,7 @@ struct dpkg_ar * dpkg_ar_fdopen(const char *filename, int fd); struct dpkg_ar *dpkg_ar_open(const char *filename); struct dpkg_ar *dpkg_ar_create(const char *filename, mode_t mode); -void dpkg_ar_set_mtime(struct dpkg_ar *ar, time_t mtime); +void dpkg_ar_set_mtime(struct dpkg_ar *ar, intmax_t mtime); void dpkg_ar_close(struct dpkg_ar *ar); void dpkg_ar_normalize_name(struct dpkg_ar_hdr *arh); diff --git a/lib/dpkg/pkg-format.c b/lib/dpkg/pkg-format.c index 17f801a07..07474a211 100644 --- a/lib/dpkg/pkg-format.c +++ b/lib/dpkg/pkg-format.c @@ -285,6 +285,7 @@ virt_fsys_last_modified(struct varbuf *vb, { const char *listfile; struct stat st; + intmax_t mtime; if (pkg->status == PKG_STAT_NOTINSTALLED) return; @@ -299,7 +300,8 @@ virt_fsys_last_modified(struct varbuf *vb, pkgbin_name_const(pkg, pkgbin, pnaw_nonambig)); } - varbuf_printf(vb, "%ld", st.st_mtime); + mtime = st.st_mtime; + varbuf_printf(vb, "%jd", mtime); } /* diff --git a/lib/dpkg/t/c-tarextract.c b/lib/dpkg/t/c-tarextract.c index 461f77f4a..882253d27 100644 --- a/lib/dpkg/t/c-tarextract.c +++ b/lib/dpkg/t/c-tarextract.c @@ -65,7 +65,7 @@ tar_object_skip(struct tar_archive *tar, struct tar_entry *te) static int tar_object(struct tar_archive *tar, struct tar_entry *te) { - printf("%s mode=%o time=%ld.%.9d uid=%d gid=%d", te->name, + printf("%s mode=%o time=%jd.%.9d uid=%d gid=%d", te->name, te->stat.mode, te->mtime, 0, te->stat.uid, te->stat.gid); if (te->stat.uname) printf(" uname=%s", te->stat.uname); diff --git a/lib/dpkg/tarfn.h b/lib/dpkg/tarfn.h index 38ab9a9fe..4d5917cfc 100644 --- a/lib/dpkg/tarfn.h +++ b/lib/dpkg/tarfn.h @@ -80,7 +80,7 @@ struct tar_entry { /** File size. */ off_t size; /** Last-modified time. */ - time_t mtime; + intmax_t mtime; /** Special device for mknod(). */ dev_t dev; -- Dpkg.Org's dpkg

