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

[misc] fix Coverity warnings

* Also re-instate the _coverity.cmd script and try to fix AppVeyor Coverity uploads
This commit is contained in:
Pete Batard 2020-06-19 10:53:40 +01:00
parent 1e85b4dbf5
commit c8078b0119
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
7 changed files with 45 additions and 17 deletions

26
_coverity.cmd Normal file
View file

@ -0,0 +1,26 @@
@rem *** Internal developer script to run Coverity ***
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
set COV_DIR=B:\cov-analysis-win64-2019.03
set PATH=%PATH%;%COV_DIR%\bin
set PWD=%~dp0
set TARGET=x86
rmdir cov-int /s /q >NUL 2>NUL
rmdir %TARGET% /s /q >NUL 2>NUL
del cov-int.zip >NUL 2>NUL
mkdir cov-int
cov-build --dir cov-int msbuild rufus.sln /p:Configuration=Release,Platform=%TARGET% /maxcpucount
rem *** for when/if Coverity manage to clean their act
rem cov-build --dir cov-int C:\msys64\usr\bin\bash -cl "export PATH=/mingw32/bin:$PATH; cd /c/rufus; ./configure --build=i686-w64-mingw32 --host=i686-w64-mingw32 --disable-debug; make -j4"
rem *** zip script by Peter Mortensen - http://superuser.com/a/111266/286681
echo Set objArgs = WScript.Arguments> zip.vbs
echo InputFolder = objArgs(0)>> zip.vbs
echo ZipFile = objArgs(1)>> zip.vbs
echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar)>> zip.vbs
echo Set objShell = CreateObject("Shell.Application")>> zip.vbs
echo Set source = objShell.NameSpace(InputFolder)>> zip.vbs
echo objShell.NameSpace(ZipFile).CopyHere(source)>> zip.vbs
echo wScript.Sleep 8000>> zip.vbs
CScript zip.vbs %PWD%cov-int %PWD%cov-int.zip
del zip.vbs
pause

View file

@ -15,8 +15,6 @@ skip_commits:
- '**/*.xml'
environment:
COVERITY_SCAN_PROJECT_NAME: "pbatard/rufus"
COVERITY_SCAN_NOTIFICATION_EMAIL: "pete@akeo.ie"
COVERITY_SCAN_TOKEN:
secure: XZADvwlRFo57sBA54pBH2oVT/eR/OytZYY/sCKq61io=
global:
@ -77,15 +75,12 @@ build_script:
C:\msys64\usr\bin\bash -lc "export PATH=/mingw$env:BITS/bin:`$PATH; cd /c/projects/rufus; mkdir -p m4; ./configure --build=$env:PLATFORM-w64-mingw32 --host=$env:PLATFORM-w64-mingw32 --disable-debug; make -j4";
}
Coverity {
$PUBLISHCOVERITY = "$env:APPVEYOR_BUILD_FOLDER\PublishCoverity\tools\PublishCoverity.exe";
if (!"$env:COVERITY_SCAN_TOKEN") {
Write-Output "Not running Coverity due to missing credential.";
return;
}
& nuget install PublishCoverity -o "$env:APPVEYOR_BUILD_FOLDER" -excludeversion;
& cov-build.exe --dir cov-int msbuild rufus.sln /m /p:Configuration=$env:CONFIGURATION,Platform=$env:PLATFORM /l:$APPVEYOR_LOGGER;
& $PUBLISHCOVERITY compress --nologo -i "$env:APPVEYOR_BUILD_FOLDER\cov-int" -o "$env:APPVEYOR_BUILD_FOLDER\coverity.zip" --overwrite;
& $PUBLISHCOVERITY publish --nologo -t $env:COVERITY_SCAN_TOKEN -e $env:COVERITY_SCAN_NOTIFICATION_EMAIL -r $env:COVERITY_SCAN_PROJECT_NAME -z "$env:APPVEYOR_BUILD_FOLDER\coverity.zip" -d "Appveyor build." --codeVersion $env:APPVEYOR_BUILD_VERSION;
Get-ChildItem -Path ./ -Recurse | Remove-Item -Force -Recurse;
cov-build.exe --dir cov-int msbuild rufus.sln /m /p:Configuration=$env:CONFIGURATION,Platform=$env:PLATFORM /l:$APPVEYOR_LOGGER;
7z a cov-int.zip cov-int
curl --form token=$env:COVERITY_SCAN_TOKEN --form email=pete@akeo.ie --form file=cov-int.zip --form version="$env:APPVEYOR_BUILD_VERSION" --form description="Appveyor build" https://scan.coverity.com/builds?project=pbatard%2Frufus
}
}

View file

@ -239,7 +239,7 @@ static inline int transformer_switch_file(transformer_state_t* xstate)
_close(xstate->dst_fd);
xstate->dst_fd = -1;
}
_snprintf_s(dst, sizeof(dst), sizeof(dst), "%s/%s", xstate->dst_dir, xstate->dst_name);
_snprintf_s(dst, sizeof(dst), _TRUNCATE, "%s/%s", xstate->dst_dir, xstate->dst_name);
for (i = 0; i < strlen(dst); i++) {
if (dst[i] == '/')
dst[i] = '\\';

View file

@ -1270,7 +1270,7 @@ BOOL ToggleEsp(DWORD DriveIndex)
r = DeviceIoControl(hPhysical, IOCTL_DISK_SET_DRIVE_LAYOUT_EX, (BYTE*)DriveLayout, size, NULL, 0, &size, NULL);
if (!r) {
uprintf("Could not set drive layout: %s", WindowsErrorString());
return FALSE;
goto out;
}
RefreshDriveLayout(hPhysical);
if (CompareGUID(&DriveLayout->PartitionEntry[i].Gpt.PartitionType, &PARTITION_GENERIC_ESP)) {
@ -1279,7 +1279,7 @@ BOOL ToggleEsp(DWORD DriveIndex)
} else if (!IsDriveLetterInUse(*mount_point)) {
// We succesfully switched ESP to Basic Data -> Try to mount it
volume_name = GetLogicalName(DriveIndex, DriveLayout->PartitionEntry[i].StartingOffset.QuadPart, TRUE, FALSE);
MountVolume(mount_point, volume_name);
IGNORE_RETVAL(MountVolume(mount_point, volume_name));
free(volume_name);
}
ret = TRUE;

View file

@ -972,6 +972,8 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
(DWORD)(SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize) : 1 * MB;
if (br_size + size > max_size) {
uprintf(" SBR size is too large - You may need to uncheck 'Add fixes for old BIOSes'.");
if (sub_type == BT_MAX)
safe_free(buf);
return FALSE;
}
@ -1468,9 +1470,12 @@ static void update_progress(const uint64_t processed_bytes)
static int sector_write(int fd, const void* _buf, unsigned int count)
{
const uint8_t* buf = (const uint8_t*)_buf;
const unsigned int sec_size = (unsigned int)SelectedDrive.SectorSize;
unsigned int sec_size = (unsigned int)SelectedDrive.SectorSize;
int written, fill_size = 0;
if (sec_size == 0)
sec_size = 512;
// If we are on a sector boundary and count is multiple of the
// sector size, just issue a regular write
if ((sec_buf_pos == 0) && (count % sec_size == 0))

View file

@ -1210,9 +1210,11 @@ char* replace_in_token_data(const char* filename, const char* token, const char*
// Output all the truncated fragments + replaced strings
for (j = 0; torep[j] != NULL; j++)
// coverity[invalid_type]
fwprintf_s(fd_out, L"%s%s", &buf[p[j]], wrep);
// Ouput the last fragment
// coverity[invalid_type]
fwprintf_s(fd_out, L"%s", &buf[p[j]]);
ret = (char*)rep;

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.11.1678"
CAPTION "Rufus 3.11.1679"
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,11,1678,0
PRODUCTVERSION 3,11,1678,0
FILEVERSION 3,11,1679,0
PRODUCTVERSION 3,11,1679,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.11.1678"
VALUE "FileVersion", "3.11.1679"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.11.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.11.1678"
VALUE "ProductVersion", "3.11.1679"
END
END
BLOCK "VarFileInfo"