From 2cf183e9f1a01023bc6c645312692aeb55c7aaf6 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 14 Sep 2022 10:58:18 +0200 Subject: [PATCH] [misc] fix Y2K38 related Coverity warnings --- src/bled/data_extract_all.c | 6 +++--- src/bled/libbb.h | 9 +++++++-- src/format_ext.c | 11 +++++++---- src/iso.c | 2 +- src/rufus.rc | 10 +++++----- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/bled/data_extract_all.c b/src/bled/data_extract_all.c index db7a4c17..83adef4d 100644 --- a/src/bled/data_extract_all.c +++ b/src/bled/data_extract_all.c @@ -195,11 +195,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) (void)_chmod(file_header->name, file_header->mode); } if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { - struct timeval t[2]; + struct timeval64 t[2]; - t[1].tv_sec = t[0].tv_sec = (long)file_header->mtime; + t[1].tv_sec = t[0].tv_sec = file_header->mtime; t[1].tv_usec = t[0].tv_usec = 0; - utimes(file_header->name, t); + utimes64(file_header->name, t); } } diff --git a/src/bled/libbb.h b/src/bled/libbb.h index 519c31cf..8eaa75c9 100644 --- a/src/bled/libbb.h +++ b/src/bled/libbb.h @@ -2,7 +2,7 @@ * Library header for busybox/Bled * * Rewritten for Bled (Base Library for Easy Decompression) - * Copyright © 2014-2020 Pete Batard + * Copyright © 2014-2022 Pete Batard * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ @@ -126,6 +126,11 @@ typedef struct _llist_t { char *data; } llist_t; +struct timeval64 { + int64_t tv_sec; + int32_t tv_usec; +}; + extern void (*bled_printf) (const char* format, ...); extern void (*bled_progress) (const uint64_t processed_bytes); extern void (*bled_switch) (const char* filename, const uint64_t filesize); @@ -160,7 +165,7 @@ static inline int link(const char *oldpath, const char *newpath) {errno = ENOSYS static inline int symlink(const char *oldpath, const char *newpath) {errno = ENOSYS; return -1;} static inline int chown(const char *path, uid_t owner, gid_t group) {errno = ENOSYS; return -1;} static inline int mknod(const char *pathname, mode_t mode, dev_t dev) {errno = ENOSYS; return -1;} -static inline int utimes(const char *filename, const struct timeval times[2]) {errno = ENOSYS; return -1;} +static inline int utimes64(const char* filename, const struct timeval64 times64[2]) { errno = ENOSYS; return -1; } static inline int fnmatch(const char *pattern, const char *string, int flags) {return PathMatchSpecA(string, pattern)?0:1;} static inline pid_t wait(int* status) { *status = 4; return -1; } #define wait_any_nohang wait diff --git a/src/format_ext.c b/src/format_ext.c index 33eec41e..ba381988 100644 --- a/src/format_ext.c +++ b/src/format_ext.c @@ -461,13 +461,16 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP int written = 0, fsize = sizeof(data) - 1; ext2_file_t ext2fd; ext2_ino_t inode_id; - uint32_t ctime = (uint32_t)time(0); + time_t ctime = time(NULL); struct ext2_inode inode = { 0 }; + // Don't care about the Y2K38 problem of ext2/ext3 for a 'persistence.conf' timestamp + if (ctime > UINT32_MAX) + ctime = UINT32_MAX; inode.i_mode = 0100644; inode.i_links_count = 1; - inode.i_atime = ctime; - inode.i_ctime = ctime; - inode.i_mtime = ctime; + inode.i_atime = (uint32_t)ctime; + inode.i_ctime = (uint32_t)ctime; + inode.i_mtime = (uint32_t)ctime; inode.i_size = fsize; ext2fs_namei(ext2fs, EXT2_ROOT_INO, EXT2_ROOT_INO, name, &inode_id); diff --git a/src/iso.c b/src/iso.c index 6d745c1e..9236c315 100644 --- a/src/iso.c +++ b/src/iso.c @@ -465,7 +465,7 @@ static LPFILETIME __inline to_filetime(time_t t) { static int i = 0; static FILETIME ft[3], *r; - LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000; + LONGLONG ll = (t * 10000000LL) + 116444736000000000LL; r = &ft[i]; r->dwLowDateTime = (DWORD)ll; diff --git a/src/rufus.rc b/src/rufus.rc index ff1ecef9..96eec074 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.21.1933" +CAPTION "Rufus 3.21.1934" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,21,1933,0 - PRODUCTVERSION 3,21,1933,0 + FILEVERSION 3,21,1934,0 + PRODUCTVERSION 3,21,1934,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.21.1933" + VALUE "FileVersion", "3.21.1934" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.21.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.21.1933" + VALUE "ProductVersion", "3.21.1934" END END BLOCK "VarFileInfo"