[misc] fix Coverity warnings

This commit is contained in:
Pete Batard 2017-07-25 12:19:50 +01:00
parent 3622b441ed
commit 0a3c04379b
4 changed files with 24 additions and 23 deletions

View File

@ -1,7 +1,7 @@
@rem *** Internal developer script to run Coverity ***
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
set COV_DIR=D:\cov-analysis-win64-8.7.0
set COV_DIR=D:\cov-analysis-win64-2017.07
set PATH=%PATH%;%COV_DIR%\bin
set PWD=%~dp0
set TARGET=x86_32

View File

@ -124,6 +124,7 @@ static errcode_t bb_u64_list_add(bb_u64_list bb, uint64_t blk)
bb->size -= 100;
return BB_ET_NO_MEMORY;
}
// coverity[suspicious_sizeof]
memset(&bb->list[bb->size-100], 0, 100 * sizeof(uint64_t));
}

View File

@ -2152,9 +2152,9 @@ static void SaveISO(void)
static BOOL CheckDriveAccess(DWORD dwTimeOut)
{
uint32_t i, j;
BOOL bProceed = TRUE;
BOOL ret = FALSE, proceed = TRUE;
BYTE access_mask;
char *PhysicalPath, DevPath[MAX_PATH];
char *PhysicalPath = NULL, DevPath[MAX_PATH];
char drive_letter[27], drive_name[] = "?:";
char *message, title[128];
DWORD cur_time, end_time = GetTickCount() + dwTimeOut;
@ -2170,16 +2170,16 @@ static BOOL CheckDriveAccess(DWORD dwTimeOut)
// Search for any blocking processes against the physical drive
PhysicalPath = GetPhysicalName(DeviceNum);
QueryDosDeviceA(&PhysicalPath[4], DevPath, sizeof(DevPath));
access_mask = SearchProcess(DevPath, dwTimeOut, TRUE, TRUE, TRUE);
CHECK_FOR_USER_CANCEL;
if (access_mask != 0) {
bProceed = FALSE;
uprintf("Found potentially blocking process(es) against %s:", &PhysicalPath[4]);
for (j = 0; j < BlockingProcess.Index; j++)
uprintf(BlockingProcess.String[j]);
if (QueryDosDeviceA(&PhysicalPath[4], DevPath, sizeof(DevPath)) != 0) {
access_mask = SearchProcess(DevPath, dwTimeOut, TRUE, TRUE, TRUE);
CHECK_FOR_USER_CANCEL;
if (access_mask != 0) {
proceed = FALSE;
uprintf("Found potentially blocking process(es) against %s:", &PhysicalPath[4]);
for (j = 0; j < BlockingProcess.Index; j++)
uprintf(BlockingProcess.String[j]);
}
}
free(PhysicalPath);
// Search for any blocking processes against the logical volume(s)
GetDriveLetters(DeviceNum, drive_letter);
@ -2194,7 +2194,7 @@ static BOOL CheckDriveAccess(DWORD dwTimeOut)
CHECK_FOR_USER_CANCEL;
// Ignore if all we have is read-only
if ((access_mask & 0x06) || (access_mask == 0x80)) {
bProceed = FALSE;
proceed = FALSE;
uprintf("Found potentially blocking process(es) against %s", drive_name);
for (j = 0; j < BlockingProcess.Index; j++)
uprintf(BlockingProcess.String[j]);
@ -2203,21 +2203,21 @@ static BOOL CheckDriveAccess(DWORD dwTimeOut)
}
// Prompt the user if we detected blocking processes
if (!bProceed) {
if (!proceed) {
// We'll use a system translated string instead of one from rufus.loc
message = GetMuiString("shell32.dll", 28701); // "This drive is in use (...) Do you want to format it anyway?"
if (message != NULL) {
ComboBox_GetTextU(hDeviceList, title, sizeof(title));
bProceed = Notification(MSG_WARNING_QUESTION, NULL, title, message);
proceed = Notification(MSG_WARNING_QUESTION, NULL, title, message);
free(message);
}
}
ret = proceed;
PrintInfo(0, MSG_210);
return bProceed;
out:
PrintInfo(0, MSG_210);
return FALSE;
free(PhysicalPath);
return ret;
}
#ifdef RUFUS_TEST

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.16.1159"
CAPTION "Rufus 2.16.1160"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -366,8 +366,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,16,1159,0
PRODUCTVERSION 2,16,1159,0
FILEVERSION 2,16,1160,0
PRODUCTVERSION 2,16,1160,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -384,13 +384,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.16.1159"
VALUE "FileVersion", "2.16.1160"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.16.1159"
VALUE "ProductVersion", "2.16.1160"
END
END
BLOCK "VarFileInfo"