[misc] fix PVS-Studio warnings

This commit is contained in:
Pete Batard 2022-01-05 12:57:26 +01:00
parent eeca1f279c
commit c28f9bc491
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
26 changed files with 98 additions and 81 deletions

View File

@ -1064,9 +1064,10 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
safe_release_dc(GetDlgItem(hDlg, IDC_MD5), hDC);
for (i=(int)safe_strlen(image_path); (i>0)&&(image_path[i]!='\\'); i--);
if (image_path != NULL) // VS code analysis has a false positive on this one
SetWindowTextU(hDlg, &image_path[i+1]);
if (image_path != NULL) {
for (i = (int)strlen(image_path); (i > 0) && (image_path[i] != '\\'); i--);
SetWindowTextU(hDlg, &image_path[i + 1]);
}
// Set focus on the OK button
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDOK), TRUE);
CenterDialog(hDlg, NULL);

View File

@ -655,6 +655,7 @@ BOOL GetDevices(DWORD devnum)
}
// Also test for "_SD&" instead of "_SD_" and so on to allow for devices like
// "SCSI\DiskRicoh_Storage_SD&REV_3.0" to be detected.
assert(strlen(scsi_card_name_copy) > 1);
scsi_card_name_copy[strlen(scsi_card_name_copy) - 1] = '&';
if (safe_strstr(buffer, scsi_card_name_copy) != NULL) {
props.is_CARD = TRUE;
@ -668,7 +669,7 @@ BOOL GetDevices(DWORD devnum)
if (!SetupDiGetDeviceInstanceIdA(dev_info, &dev_info_data, device_instance_id,
sizeof(device_instance_id), &size)) {
uprintf("SetupDiGetDeviceInstanceId failed: %s", WindowsErrorString());
static_strcpy(device_instance_id, "<N/A>");
strcpy(device_instance_id, "<N/A>");
}
memset(buffer, 0, sizeof(buffer));

View File

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* DOS keyboard locale setup
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2021 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -982,6 +982,7 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
kb = "us";
kbdrv = bFreeDOS?fd_get_kbdrv(kb):ms_get_kbdrv(kb); // Always succeeds
}
assert(kbdrv >= 0);
uprintf("Will use DOS keyboard '%s' [%s]\n", kb, kb_to_hr(kb));
// Now get a codepage

View File

@ -301,8 +301,8 @@ errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
if (!num)
num = 1;
c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
b &= ~(c_ratio - 1);
finish &= ~(c_ratio -1);
b &= ~((blk64_t)c_ratio - 1);
finish &= ~((blk64_t)c_ratio - 1);
do {
if (b + num - 1 >= ext2fs_blocks_count(fs->super)) {
if (finish > start)

View File

@ -1438,7 +1438,7 @@ static errcode_t xattr_array_update(struct ext2_xattr_handle *h,
return 0;
}
if (h->ibody_count <= old_idx) {
if (old_idx >= 0 && h->ibody_count <= old_idx) {
block_free += EXT2_EXT_ATTR_LEN(name_len);
if (!h->attrs[old_idx].ea_ino)
block_free +=

View File

@ -357,13 +357,8 @@ ext2fs_file_write_inline_data(ext2_file_t file, const void *buf,
file->pos += count;
/* Update inode size */
if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos) {
errcode_t rc;
rc = ext2fs_file_set_size2(file, file->pos);
if (retval == 0)
retval = rc;
}
if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos)
retval = ext2fs_file_set_size2(file, file->pos);
if (written)
*written = count;

View File

@ -117,7 +117,7 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
} else
bitmap->description = 0;
size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
size = (((size_t)bitmap->real_end - bitmap->start) / 8) + 1;
/* Round up to allow for the BT x86 instruction */
size = (size + 7) & ~3;
retval = ext2fs_get_mem(size, &bitmap->bitmap);
@ -303,7 +303,7 @@ void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
}
memset(bitmap32->bitmap, 0,
(size_t) (((bitmap32->real_end - bitmap32->start) / 8) + 1));
(((size_t)bitmap32->real_end - bitmap32->start) / 8) + 1);
}
errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap gen_bitmap,

View File

@ -87,10 +87,11 @@ void ext2fs_free_inode_cache(struct ext2_inode_cache *icache)
return;
if (icache->buffer)
ext2fs_free_mem(&icache->buffer);
for (i = 0; i < icache->cache_size; i++)
ext2fs_free_mem(&icache->cache[i].inode);
if (icache->cache)
if (icache->cache) {
for (i = 0; i < icache->cache_size; i++)
ext2fs_free_mem(&icache->cache[i].inode);
ext2fs_free_mem(&icache->cache);
}
icache->buffer_blk = 0;
ext2fs_free_mem(&icache);
}

View File

@ -278,7 +278,7 @@ static __inline BOOLEAN _IsMounted(IN HANDLE Handle)
{
IO_STATUS_BLOCK IoStatusBlock;
PF_INIT(NtFsControlFile, NtDll);
return (pfNtFsControlFile == NULL) ? STATUS_DLL_NOT_FOUND :
return (pfNtFsControlFile == NULL) ? FALSE :
(BOOLEAN)(pfNtFsControlFile(Handle, 0, 0, 0, &IoStatusBlock, FSCTL_IS_VOLUME_MOUNTED, 0, 0, 0, 0) == STATUS_SUCCESS);
}

View File

@ -1175,6 +1175,7 @@ static BOOL SetupWinPE(char drive_letter)
for (i=1; i<size-32; i++) {
for (j=0; j<ARRAYSIZE(patch_str_org); j++) {
if (safe_strnicmp(&buffer[i], patch_str_org[j], strlen(patch_str_org[j])-1) == 0) {
assert(index < 2);
uprintf(" 0x%08X: '%s' -> '%s'\n", i, &buffer[i], patch_str_rep[index][j]);
strcpy(&buffer[i], patch_str_rep[index][j]);
i += (DWORD)max(strlen(patch_str_org[j]), strlen(patch_str_rep[index][j])); // in case org is a substring of rep
@ -2093,6 +2094,7 @@ DWORD WINAPI FormatThread(void* param)
if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) {
PrintInfoDebug(0, MSG_227);
if (!CloseHandle(hLogicalVolume)) {
hLogicalVolume = INVALID_HANDLE_VALUE;
uprintf("Could not close volume: %s", WindowsErrorString());
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_ACCESS_DENIED;
goto out;

View File

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* extfs formatting
* Copyright © 2019-2020 Pete Batard <pete@akeo.ie>
* Copyright © 2019-2021 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -212,6 +212,7 @@ const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset)
r = ext2fs_open(volume_name, EXT2_FLAG_SKIP_MMP, 0, 0, manager, &ext2fs);
free(volume_name);
if (r == 0) {
assert(ext2fs != NULL);
strncpy(label, ext2fs->super->s_volume_name, EXT2_LABEL_LEN);
label[EXT2_LABEL_LEN] = 0;
}

View File

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility
* Large FAT32 formatting
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2021 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -414,7 +414,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
}
for (i = 0; i < (SystemAreaSize + BurstSize - 1); i += BurstSize) {
UpdateProgressWithInfo(OP_FORMAT, MSG_217, (uint64_t)i, (uint64_t)(SystemAreaSize + BurstSize));
UpdateProgressWithInfo(OP_FORMAT, MSG_217, (uint64_t)i, (uint64_t)SystemAreaSize + BurstSize);
CHECK_FOR_USER_CANCEL;
if (write_sectors(hLogicalVolume, BytesPerSect, i, BurstSize, pZeroSect) != (BytesPerSect * BurstSize)) {
die("Error clearing reserved sectors", ERROR_WRITE_FAULT);

View File

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Extract icon from executable and set autorun.inf
* Copyright © 2012-2019 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2021 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "rufus.h"
#include "missing.h"
@ -185,7 +186,8 @@ BOOL SetAutorun(const char* path)
uprintf("Created: %s", filename);
// .inf -> .ico
filename[strlen(filename)-1] = 'o';
filename[strlen(filename)-2] = 'c';
assert(strlen(filename) >= 2);
filename[strlen(filename) - 1] = 'o';
filename[strlen(filename) - 2] = 'c';
return ExtractAppIcon(filename, FALSE);
}

View File

@ -180,7 +180,7 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t file_length, const
// Check for archiso loader/entries/*.conf files
if (safe_stricmp(psz_dirname, "/loader/entries") == 0) {
len = strlen(psz_basename);
len = safe_strlen(psz_basename);
props->is_conf = ((len > 4) && (stricmp(&psz_basename[len - 5], ".conf") == 0));
}
@ -863,7 +863,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
size_t i, j, size, sl_index = 0;
uint16_t sl_version;
FILE* fd;
int r = 1;
int k, r = 1;
iso9660_t* p_iso = NULL;
iso9660_pvd_t pvd;
udf_t* p_udf = NULL;
@ -969,8 +969,8 @@ out:
if ((iso9660_ifs_read_pvd(p_iso, &pvd)) && (_stat64U(src_iso, &stat) == 0))
img_report.mismatch_size = (int64_t)(iso9660_get_pvd_space_size(&pvd)) * ISO_BLOCKSIZE - stat.st_size;
// Remove trailing spaces from the label
for (j=safe_strlen(img_report.label)-1; ((j>0)&&(isspaceU(img_report.label[j]))); j--)
img_report.label[j] = 0;
for (k=(int)safe_strlen(img_report.label)-1; ((k>0)&&(isspaceU(img_report.label[k]))); k--)
img_report.label[k] = 0;
// We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here
img_report.projected_size = total_blocks * ISO_BLOCKSIZE;
// We will link the existing isolinux.cfg from a syslinux.cfg we create

View File

@ -937,7 +937,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir,
if (su_length % 2)
su_length--;
if (su_length < 0 || su_length < sizeof (iso9660_xa_t))
if (su_length < sizeof (iso9660_xa_t))
return p_stat;
if (nope == b_xa) {

View File

@ -89,12 +89,12 @@ static __inline uint8_t popcnt8(uint8_t val)
static __inline uint8_t popcnt64(register uint64_t u)
{
u = (u & 0x5555555555555555) + ((u >> 1) & 0x5555555555555555);
u = (u & 0x3333333333333333) + ((u >> 2) & 0x3333333333333333);
u = (u & 0x0f0f0f0f0f0f0f0f) + ((u >> 4) & 0x0f0f0f0f0f0f0f0f);
u = (u & 0x00ff00ff00ff00ff) + ((u >> 8) & 0x00ff00ff00ff00ff);
u = (u & 0x0000ffff0000ffff) + ((u >> 16) & 0x0000ffff0000ffff);
u = (u & 0x00000000ffffffff) + ((u >> 32) & 0x00000000ffffffff);
u = (u & 0x5555555555555555ULL) + ((u >> 1) & 0x5555555555555555ULL);
u = (u & 0x3333333333333333ULL) + ((u >> 2) & 0x3333333333333333ULL);
u = (u & 0x0f0f0f0f0f0f0f0fULL) + ((u >> 4) & 0x0f0f0f0f0f0f0f0fULL);
u = (u & 0x00ff00ff00ff00ffULL) + ((u >> 8) & 0x00ff00ff00ff00ffULL);
u = (u & 0x0000ffff0000ffffULL) + ((u >> 16) & 0x0000ffff0000ffffULL);
u = (u & 0x00000000ffffffffULL) + ((u >> 32) & 0x00000000ffffffffULL);
return (uint8_t)u;
}

View File

@ -821,7 +821,7 @@ static __inline int SHDeleteDirectoryExU(HWND hwnd, const char* pszPath, FILEOP_
int ret;
// String needs to be double NULL terminated, so we just use the length of the UTF-8 string
// which is always expected to be larger than our UTF-16 one, and add 2 chars for good measure.
size_t wpszPath_len = strlen(pszPath) + 2;
size_t wpszPath_len = (pszPath == NULL) ? 0 : strlen(pszPath) + 2;
// coverity[returned_null]
walloc(pszPath, wpszPath_len);
SHFILEOPSTRUCTW shfo = { hwnd, FO_DELETE, wpszPath, NULL, fFlags, FALSE, NULL, NULL };

View File

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Elementary Unicode compliant find/replace parser
* Copyright © 2012-2020 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2021 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -796,13 +796,20 @@ char* set_token_data_file(const char* token, const char* data, const char* filen
}
out:
if (fd_in != NULL) fclose(fd_in);
if (fd_out != NULL) fclose(fd_out);
if (fd_in != NULL) {
fclose(fd_in);
fd_in = NULL;
}
if (fd_out != NULL) {
fclose(fd_out);
fd_out = NULL;
}
// If an insertion occurred, delete existing file and use the new one
if (ret != NULL) {
// We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb");
if (wtmpname != NULL)
fd_in = _wfopen(wtmpname, L"rb");
fd_out = _wfopen(wfilename, L"wb");
// Don't check fds
if ((fd_in != NULL) && (fd_out != NULL)) {
@ -1052,7 +1059,7 @@ out:
if (fd_out != NULL) fclose(fd_out);
// If an insertion occurred, delete existing file and use the new one
if (ret != NULL) {
if (ret != NULL && wtmpname != NULL && wfilename != NULL) {
// We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb");
fd_out = _wfopen(wfilename, L"wb");
@ -1229,7 +1236,7 @@ out:
if (fd_out != NULL) fclose(fd_out);
// If a replacement occurred, delete existing file and use the new one
if (ret != NULL) {
if (ret != NULL && wtmpname != NULL && wfilename != NULL) {
// We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb");
fd_out = _wfopen(wfilename, L"wb");

View File

@ -4,7 +4,7 @@
*
* Modified from Process Hacker:
* https://github.com/processhacker2/processhacker2/
* Copyright © 2017-2020 Pete Batard <pete@akeo.ie>
* Copyright © 2017-2021 Pete Batard <pete@akeo.ie>
* Copyright © 2017 dmex
* Copyright © 2009-2016 wj32
*
@ -506,6 +506,9 @@ static DWORD WINAPI SearchProcessThread(LPVOID param)
if (i >= handles->NumberOfHandles)
break;
if (handleInfo == NULL)
continue;
// Don't bother with processes we can't access
if (handleInfo->UniqueProcessId == last_access_denied_pid)
continue;
@ -609,7 +612,7 @@ static DWORD WINAPI SearchProcessThread(LPVOID param)
// The above may not work on Windows 7, so try QueryFullProcessImageName (Vista or later)
if (!bGotCmdLine) {
bGotCmdLine = QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size);
bGotCmdLine = (QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size) != FALSE);
if (bGotCmdLine)
wchar_to_utf8_no_alloc(wexe_path, cmdline, sizeof(cmdline));
}

View File

@ -751,9 +751,6 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes)
actual_enable_mbr = FALSE;
mbr_selected_by_user = FALSE;
}
if (boot_type == BT_NON_BOOTABLE) {
actual_enable_fix = FALSE;
}
}
if (remove_checkboxes) {
@ -1135,6 +1132,7 @@ static void DisplayISOProps(void)
PRINT_ISO_PROP(HAS_WINPE(img_report), " Uses: WinPE %s", (img_report.uses_minint) ? "(with /minint)" : "");
if (HAS_WININST(img_report)) {
inst_str[4] = '0' + img_report.wininst_index;
assert(strlen(img_report.wininst_path[0]) >= 3);
uprintf(" Uses: Install.%s%s (version %d.%d.%d%s)", &img_report.wininst_path[0][strlen(img_report.wininst_path[0]) - 3],
(img_report.wininst_index > 1) ? inst_str : "", (img_report.wininst_version >> 24) & 0xff,
(img_report.wininst_version >> 16) & 0xff, (img_report.wininst_version >> 8) & 0xff,
@ -2218,6 +2216,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
static SHChangeNotifyEntry NotifyEntry;
static DWORD_PTR thread_affinity[CHECKSUM_MAX + 1];
static HFONT hyperlink_font = NULL;
static wchar_t wtooltip[128];
LONG lPos;
BOOL set_selected_fs;
DRAWITEMSTRUCT* pDI;
@ -2234,7 +2233,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
char tmp[MAX_PATH], *log_buffer = NULL;
wchar_t* wbuffer = NULL;
loc_cmd* lcmd = NULL;
wchar_t wtooltip[128];
switch (message) {

View File

@ -132,7 +132,7 @@
#ifndef STRINGIFY
#define STRINGIFY(x) #x
#endif
#define PERCENTAGE(percent, value) ((1ULL * percent * value) / 100ULL)
#define PERCENTAGE(percent, value) ((1ULL * (percent) * (value)) / 100ULL)
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0)
#define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) goto out
@ -149,7 +149,7 @@
((char*)(dst))[safe_min(count, dst_max)-1] = 0;} while(0)
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
#define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src)
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1))
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, (dst_max) - safe_strlen(dst) - 1))
#define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
#define static_strcat(dst, src) safe_strcat(dst, sizeof(dst), src)
#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
@ -178,7 +178,7 @@ extern void _uprintfs(const char *str);
#define vvuprintf(...) do { if (verbose > 1) _uprintf(__VA_ARGS__); } while(0)
#define suprintf(...) do { if (!bSilent) _uprintf(__VA_ARGS__); } while(0)
#define uuprintf(...) do { if (usb_debug) _uprintf(__VA_ARGS__); } while(0)
#define ubprintf(...) do { safe_sprintf(&ubuffer[ubuffer_pos], UBUFFER_SIZE - ubuffer_pos - 2, __VA_ARGS__); \
#define ubprintf(...) do { safe_sprintf(&ubuffer[ubuffer_pos], UBUFFER_SIZE - ubuffer_pos - 4, __VA_ARGS__); \
ubuffer_pos = strlen(ubuffer); ubuffer[ubuffer_pos++] = '\r'; ubuffer[ubuffer_pos++] = '\n'; \
ubuffer[ubuffer_pos] = 0; } while(0)
#define ubflush() do { if (ubuffer_pos) uprintf("%s", ubuffer); ubuffer_pos = 0; } while(0)
@ -389,7 +389,7 @@ typedef struct {
BOOLEAN has_kolibrios;
BOOLEAN uses_casper;
BOOLEAN uses_minint;
BOOLEAN compression_type;
uint8_t compression_type;
winver_t win_version; // Windows ISO version
uint16_t sl_version; // Syslinux/Isolinux version
char sl_version_str[12];

View File

@ -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.18.1854"
CAPTION "Rufus 3.18.1855"
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,18,1854,0
PRODUCTVERSION 3,18,1854,0
FILEVERSION 3,18,1855,0
PRODUCTVERSION 3,18,1855,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.18.1854"
VALUE "FileVersion", "3.18.1855"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.18.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.18.1854"
VALUE "ProductVersion", "3.18.1855"
END
END
BLOCK "VarFileInfo"

View File

@ -662,7 +662,7 @@ const char *WindowsErrorString(void)
size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
HRESULT_CODE(error_code), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
&err_string[presize], sizeof(err_string)-(DWORD)strlen(err_string), NULL);
&err_string[presize], (DWORD)(sizeof(err_string)-strlen(err_string)), NULL);
if (size == 0) {
format_error = GetLastError();
if ((format_error) && (format_error != ERROR_MR_MID_NOT_FOUND) && (format_error != ERROR_MUI_FILE_NOT_LOADED))

View File

@ -155,9 +155,12 @@ void BrowseForFolder(void) {
dialog_showing++;
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileOpenDialog, (LPVOID)&pfod);
if (FAILED(hr)) {
if (FAILED(hr) || pfod == NULL) {
uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr);
pfod = NULL; // Just in case
if (pfod != NULL) {
IFileOpenDialog_Release(pfod);
pfod = NULL; // Just in case
}
goto fallback;
}
hr = IFileOpenDialog_SetOptions(pfod, FOS_PICKFOLDERS);
@ -180,7 +183,7 @@ void BrowseForFolder(void) {
}
hr = SHCreateItemFromParsingName(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) {
if (SUCCEEDED(hr) && pfod != NULL) {
if (wpath != NULL) {
IFileOpenDialog_SetFolder(pfod, si_path);
}
@ -191,7 +194,7 @@ void BrowseForFolder(void) {
safe_free(wpath);
hr = IFileOpenDialog_Show(pfod, hMainDialog);
if (SUCCEEDED(hr)) {
if (SUCCEEDED(hr) && pfod != NULL) {
hr = IFileOpenDialog_GetResult(pfod, &psi);
if (SUCCEEDED(hr)) {
IShellItem_GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath);
@ -277,7 +280,10 @@ char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options)
if (FAILED(hr)) {
SetLastError(hr);
uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString());
pfd = NULL; // Just in case
if (pfd != NULL) {
IFileDialog_Release(pfd);
pfd = NULL; // Just in case
}
goto fallback;
}
@ -789,8 +795,8 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
case IDC_MORE_INFO:
assert(notification_more_info->callback != NULL);
if (notification_more_info != NULL) {
assert(notification_more_info->callback != NULL);
if (notification_more_info->id == MORE_INFO_URL) {
ShellExecuteA(hDlg, "open", notification_more_info->url, NULL, NULL, SW_SHOWNORMAL);
} else {
@ -1613,7 +1619,7 @@ BOOL SetUpdateCheck(void)
}
// If the user hasn't set the interval in the dialog, set to default
if ( (ReadSetting32(SETTING_UPDATE_INTERVAL) == 0) ||
((ReadSetting32(SETTING_UPDATE_INTERVAL) == -1) && enable_updates) )
(ReadSetting32(SETTING_UPDATE_INTERVAL) == -1) )
WriteSetting32(SETTING_UPDATE_INTERVAL, 86400);
}
SetFidoCheck();
@ -2005,7 +2011,7 @@ static BOOL CALLBACK AlertPromptCallback(HWND hWnd, LPARAM lParam)
if (GetWindowTextU(hWnd, str, sizeof(str)) == 0)
return TRUE;
if (safe_strcmp(str, button_str) == 0)
if (strcmp(str, button_str) == 0)
*found = TRUE;
return TRUE;
}

View File

@ -194,7 +194,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
}
/* Create ldlinux.sys file */
static_sprintf(path, "%C:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[0]);
static_sprintf(path, "%c:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[0]);
f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS,
@ -236,7 +236,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
switch (file_system) {
case FS_NTFS:
static_sprintf(tmp, "%C:\\", drive_letter);
static_sprintf(tmp, "%c:\\", drive_letter);
vol_info.Handle = d_handle;
err = NtfsSectGetVolumeInfo(tmp, &vol_info);
if (err != ERROR_SUCCESS) {
@ -333,7 +333,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
IGNORE_RETVAL(_chdirU(app_data_dir));
static_sprintf(path, "%s\\%s-%s", FILES_DIR, syslinux, embedded_sl_version_str[1]);
IGNORE_RETVAL(_chdir(path));
static_sprintf(path, "%C:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[2]);
static_sprintf(path, "%c:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[2]);
fd = fopen(&path[3], "rb");
if (fd == NULL) {
uprintf("Caution: No '%s' was provided. The target will be missing a required Syslinux file!", &path[3]);
@ -354,7 +354,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
goto out;
}
/* Create mboot.c32 file */
static_sprintf(path, "%C:\\%s", drive_letter, mboot_c32);
static_sprintf(path, "%c:\\%s", drive_letter, mboot_c32);
f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@ -368,7 +368,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
goto out;
}
safe_closehandle(f_handle);
static_sprintf(path, "%C:\\syslinux.cfg", drive_letter);
static_sprintf(path, "%c:\\syslinux.cfg", drive_letter);
fd = fopen(path, "w");
if (fd == NULL) {
uprintf("Could not create ReactOS 'syslinux.cfg'");

View File

@ -575,8 +575,9 @@ void SetSectionHeaders(HWND hDlg)
SendDlgItemMessageA(hDlg, section_control_ids[i], WM_SETFONT, (WPARAM)hf, TRUE);
hCtrl = GetDlgItem(hDlg, section_control_ids[i]);
memset(wtmp, 0, sizeof(wtmp));
GetWindowTextW(hCtrl, wtmp, ARRAYSIZE(wtmp) - 3);
GetWindowTextW(hCtrl, wtmp, ARRAYSIZE(wtmp) - 4);
wlen = wcslen(wtmp);
assert(wlen < ARRAYSIZE(wtmp - 2));
wtmp[wlen++] = L' ';
wtmp[wlen++] = L' ';
SetWindowTextW(hCtrl, wtmp);
@ -788,8 +789,7 @@ void ToggleImageOptions(void)
if (image_option_txt[0] == 0)
GetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), image_option_txt, sizeof(image_option_txt));
if ( ((has_wintogo) && !(image_options & IMOP_WINTOGO)) ||
((!has_wintogo) && (image_options & IMOP_WINTOGO)) ) {
if ((has_wintogo) != (image_options & IMOP_WINTOGO)) {
image_options ^= IMOP_WINTOGO;
if (image_options & IMOP_WINTOGO) {
// Set the Windows To Go selection in the dropdown
@ -797,8 +797,7 @@ void ToggleImageOptions(void)
}
}
if (((has_persistence) && !(image_options & IMOP_PERSISTENCE)) ||
((!has_persistence) && (image_options & IMOP_PERSISTENCE))) {
if ((has_persistence) != (image_options & IMOP_PERSISTENCE)) {
image_options ^= IMOP_PERSISTENCE;
if (image_options & IMOP_PERSISTENCE) {
SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), lmprintf(MSG_123));
@ -1069,7 +1068,7 @@ void CreateAdditionalControls(HWND hDlg)
hAdvancedDeviceToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, TOOLBAR_STYLE,
0, 0, 0, 0, hMainDialog, (HMENU)IDC_ADVANCED_DEVICE_TOOLBAR, hMainInstance, NULL);
SendMessage(hAdvancedDeviceToolbar, CCM_SETVERSION, (WPARAM)6, 0);
memset(tbToolbarButtons, 0, sizeof(TBBUTTON));
memset(tbToolbarButtons, 0, sizeof(tbToolbarButtons));
tbToolbarButtons[0].idCommand = IDC_ADVANCED_DRIVE_PROPERTIES;
tbToolbarButtons[0].fsStyle = BTNS_SHOWTEXT | BTNS_AUTOSIZE;
tbToolbarButtons[0].fsState = TBSTATE_ENABLED;
@ -1091,7 +1090,7 @@ void CreateAdditionalControls(HWND hDlg)
hAdvancedFormatToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, TOOLBAR_STYLE,
0, 0, 0, 0, hMainDialog, (HMENU)IDC_ADVANCED_FORMAT_TOOLBAR, hMainInstance, NULL);
SendMessage(hAdvancedFormatToolbar, CCM_SETVERSION, (WPARAM)6, 0);
memset(tbToolbarButtons, 0, sizeof(TBBUTTON));
memset(tbToolbarButtons, 0, sizeof(tbToolbarButtons));
tbToolbarButtons[0].idCommand = IDC_ADVANCED_FORMAT_OPTIONS;
tbToolbarButtons[0].fsStyle = BTNS_SHOWTEXT | BTNS_AUTOSIZE;
tbToolbarButtons[0].fsState = TBSTATE_ENABLED;