1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] fix Y2K38 related Coverity warnings

This commit is contained in:
Pete Batard 2022-09-14 10:58:18 +02:00
parent d9e8b8caeb
commit 2cf183e9f1
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
5 changed files with 23 additions and 15 deletions

View file

@ -195,11 +195,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
(void)_chmod(file_header->name, file_header->mode); (void)_chmod(file_header->name, file_header->mode);
} }
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { 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; t[1].tv_usec = t[0].tv_usec = 0;
utimes(file_header->name, t); utimes64(file_header->name, t);
} }
} }

View file

@ -2,7 +2,7 @@
* Library header for busybox/Bled * Library header for busybox/Bled
* *
* Rewritten for Bled (Base Library for Easy Decompression) * Rewritten for Bled (Base Library for Easy Decompression)
* Copyright © 2014-2020 Pete Batard <pete@akeo.ie> * Copyright © 2014-2022 Pete Batard <pete@akeo.ie>
* *
* Licensed under GPLv2 or later, see file LICENSE in this source tree. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/ */
@ -126,6 +126,11 @@ typedef struct _llist_t {
char *data; char *data;
} llist_t; } llist_t;
struct timeval64 {
int64_t tv_sec;
int32_t tv_usec;
};
extern void (*bled_printf) (const char* format, ...); extern void (*bled_printf) (const char* format, ...);
extern void (*bled_progress) (const uint64_t processed_bytes); extern void (*bled_progress) (const uint64_t processed_bytes);
extern void (*bled_switch) (const char* filename, const uint64_t filesize); 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 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 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 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 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; } static inline pid_t wait(int* status) { *status = 4; return -1; }
#define wait_any_nohang wait #define wait_any_nohang wait

View file

@ -461,13 +461,16 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP
int written = 0, fsize = sizeof(data) - 1; int written = 0, fsize = sizeof(data) - 1;
ext2_file_t ext2fd; ext2_file_t ext2fd;
ext2_ino_t inode_id; ext2_ino_t inode_id;
uint32_t ctime = (uint32_t)time(0); time_t ctime = time(NULL);
struct ext2_inode inode = { 0 }; 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_mode = 0100644;
inode.i_links_count = 1; inode.i_links_count = 1;
inode.i_atime = ctime; inode.i_atime = (uint32_t)ctime;
inode.i_ctime = ctime; inode.i_ctime = (uint32_t)ctime;
inode.i_mtime = ctime; inode.i_mtime = (uint32_t)ctime;
inode.i_size = fsize; inode.i_size = fsize;
ext2fs_namei(ext2fs, EXT2_ROOT_INO, EXT2_ROOT_INO, name, &inode_id); ext2fs_namei(ext2fs, EXT2_ROOT_INO, EXT2_ROOT_INO, name, &inode_id);

View file

@ -465,7 +465,7 @@ static LPFILETIME __inline to_filetime(time_t t)
{ {
static int i = 0; static int i = 0;
static FILETIME ft[3], *r; static FILETIME ft[3], *r;
LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000; LONGLONG ll = (t * 10000000LL) + 116444736000000000LL;
r = &ft[i]; r = &ft[i];
r->dwLowDateTime = (DWORD)ll; r->dwLowDateTime = (DWORD)ll;

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.21.1933" CAPTION "Rufus 3.21.1934"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,21,1933,0 FILEVERSION 3,21,1934,0
PRODUCTVERSION 3,21,1933,0 PRODUCTVERSION 3,21,1934,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.21.1933" VALUE "FileVersion", "3.21.1934"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.21.exe" VALUE "OriginalFilename", "rufus-3.21.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.21.1933" VALUE "ProductVersion", "3.21.1934"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"