mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-24 12:03:28 +01:00
Windows: Fix warnings reported by Coverity static code analyzer
This commit is contained in:
parent
a7b61ce5e5
commit
c1d670fd75
@ -5529,11 +5529,11 @@ static void DisplayBenchmarkResults (HWND hwndDlg)
|
|||||||
SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem);
|
SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem);
|
||||||
break;
|
break;
|
||||||
case BENCHMARK_TYPE_PRF:
|
case BENCHMARK_TYPE_PRF:
|
||||||
swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d ms", benchmarkTable[i].meanBytesPerSec);
|
swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d ms", (int) benchmarkTable[i].meanBytesPerSec);
|
||||||
LvItem.iSubItem = 1;
|
LvItem.iSubItem = 1;
|
||||||
LvItem.pszText = item1;
|
LvItem.pszText = item1;
|
||||||
SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem);
|
SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem);
|
||||||
swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d", benchmarkTable[i].decSpeed);
|
swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d", (int) benchmarkTable[i].decSpeed);
|
||||||
LvItem.iSubItem = 2;
|
LvItem.iSubItem = 2;
|
||||||
LvItem.pszText = item1;
|
LvItem.pszText = item1;
|
||||||
SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem);
|
SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem);
|
||||||
@ -7530,7 +7530,10 @@ int GetLastAvailableDrive ()
|
|||||||
|
|
||||||
BOOL IsDriveAvailable (int driveNo)
|
BOOL IsDriveAvailable (int driveNo)
|
||||||
{
|
{
|
||||||
|
if (driveNo >= 0 && driveNo < 26)
|
||||||
return (GetUsedLogicalDrives() & (1 << driveNo)) == 0;
|
return (GetUsedLogicalDrives() & (1 << driveNo)) == 0;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -13057,7 +13060,7 @@ BOOL IsApplicationInstalled (const wchar_t *appName, BOOL b32bitApp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wchar_t regName[1024];
|
wchar_t regName[1024];
|
||||||
DWORD regNameSize = sizeof (regName);
|
DWORD regNameSize = ARRAYSIZE (regName);
|
||||||
DWORD index = 0;
|
DWORD index = 0;
|
||||||
while (RegEnumKeyEx (unistallKey, index++, regName, ®NameSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
while (RegEnumKeyEx (unistallKey, index++, regName, ®NameSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -515,6 +515,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
|
|||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
CRYPTO_INFO tmpCI;
|
CRYPTO_INFO tmpCI;
|
||||||
PCRYPTO_INFO cryptoInfoBackup = NULL;
|
PCRYPTO_INFO cryptoInfoBackup = NULL;
|
||||||
|
BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pVolumePassword->Length == 0) return -1;
|
if (pVolumePassword->Length == 0) return -1;
|
||||||
@ -684,7 +685,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo));
|
VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo));
|
||||||
}
|
}
|
||||||
@ -856,7 +857,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
|
|||||||
DebugAddProgressDlgStatus(hwndDlg, L"Writing re-encrypted primary header ...\r\n");
|
DebugAddProgressDlgStatus(hwndDlg, L"Writing re-encrypted primary header ...\r\n");
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VirtualLock (&tmpCI, sizeof (CRYPTO_INFO));
|
VirtualLock (&tmpCI, sizeof (CRYPTO_INFO));
|
||||||
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
|
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
|
||||||
@ -886,7 +887,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
|
|||||||
FALSE ); // use slow poll
|
FALSE ); // use slow poll
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
cryptoInfo = cryptoInfoBackup;
|
cryptoInfo = cryptoInfoBackup;
|
||||||
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
||||||
@ -926,7 +927,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
|
|||||||
LARGE_INTEGER hiddenOffset;
|
LARGE_INTEGER hiddenOffset;
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VirtualLock (&tmpCI, sizeof (CRYPTO_INFO));
|
VirtualLock (&tmpCI, sizeof (CRYPTO_INFO));
|
||||||
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
|
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
|
||||||
@ -938,7 +939,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
|
|||||||
|
|
||||||
nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, newDataAreaSize, !backupHeader, backupHeader);
|
nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, newDataAreaSize, !backupHeader, backupHeader);
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
cryptoInfo = cryptoInfoBackup;
|
cryptoInfo = cryptoInfoBackup;
|
||||||
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
||||||
|
@ -774,6 +774,9 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
|||||||
int pim = volParams->pim;
|
int pim = volParams->pim;
|
||||||
DISK_GEOMETRY driveGeometry;
|
DISK_GEOMETRY driveGeometry;
|
||||||
HWND hwndDlg = volParams->hwndDlg;
|
HWND hwndDlg = volParams->hwndDlg;
|
||||||
|
#ifdef _WIN64
|
||||||
|
BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bInPlaceEncNonSysResumed = TRUE;
|
bInPlaceEncNonSysResumed = TRUE;
|
||||||
@ -870,7 +873,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
|||||||
goto closing_seq;
|
goto closing_seq;
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VcProtectKeys (masterCryptoInfo, VcGetEncryptionID (masterCryptoInfo));
|
VcProtectKeys (masterCryptoInfo, VcGetEncryptionID (masterCryptoInfo));
|
||||||
VcProtectKeys (headerCryptoInfo, VcGetEncryptionID (headerCryptoInfo));
|
VcProtectKeys (headerCryptoInfo, VcGetEncryptionID (headerCryptoInfo));
|
||||||
@ -1100,7 +1103,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
|||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
CRYPTO_INFO tmpCI;
|
CRYPTO_INFO tmpCI;
|
||||||
PCRYPTO_INFO cryptoInfoBackup = NULL;
|
PCRYPTO_INFO cryptoInfoBackup = NULL;
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VirtualLock (&tmpCI, sizeof(tmpCI));
|
VirtualLock (&tmpCI, sizeof(tmpCI));
|
||||||
memcpy (&tmpCI, masterCryptoInfo, sizeof (CRYPTO_INFO));
|
memcpy (&tmpCI, masterCryptoInfo, sizeof (CRYPTO_INFO));
|
||||||
@ -1129,7 +1132,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
|||||||
wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1));
|
wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1));
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
masterCryptoInfo = cryptoInfoBackup;
|
masterCryptoInfo = cryptoInfoBackup;
|
||||||
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
||||||
@ -1151,7 +1154,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VirtualLock (&tmpCI, sizeof(tmpCI));
|
VirtualLock (&tmpCI, sizeof(tmpCI));
|
||||||
memcpy (&tmpCI, headerCryptoInfo, sizeof (CRYPTO_INFO));
|
memcpy (&tmpCI, headerCryptoInfo, sizeof (CRYPTO_INFO));
|
||||||
@ -1164,7 +1167,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
|||||||
nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE);
|
nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE);
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
headerCryptoInfo = cryptoInfoBackup;
|
headerCryptoInfo = cryptoInfoBackup;
|
||||||
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
burn (&tmpCI, sizeof (CRYPTO_INFO));
|
||||||
@ -1331,6 +1334,9 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
|
|||||||
int pkcs5_prf = volParams->pkcs5;
|
int pkcs5_prf = volParams->pkcs5;
|
||||||
int pim = volParams->pim;
|
int pim = volParams->pim;
|
||||||
DISK_GEOMETRY driveGeometry;
|
DISK_GEOMETRY driveGeometry;
|
||||||
|
#ifdef _WIN64
|
||||||
|
BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
|
buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
|
||||||
@ -1438,7 +1444,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
|
|||||||
goto closing_seq;
|
goto closing_seq;
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled ())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
VcProtectKeys (masterCryptoInfo, VcGetEncryptionID (masterCryptoInfo));
|
VcProtectKeys (masterCryptoInfo, VcGetEncryptionID (masterCryptoInfo));
|
||||||
VcProtectKeys (headerCryptoInfo, VcGetEncryptionID (headerCryptoInfo));
|
VcProtectKeys (headerCryptoInfo, VcGetEncryptionID (headerCryptoInfo));
|
||||||
@ -1840,6 +1846,9 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN
|
|||||||
uint32 headerCrc32;
|
uint32 headerCrc32;
|
||||||
byte *fieldPos;
|
byte *fieldPos;
|
||||||
PCRYPTO_INFO pCryptoInfo = headerCryptoInfo;
|
PCRYPTO_INFO pCryptoInfo = headerCryptoInfo;
|
||||||
|
#ifdef _WIN64
|
||||||
|
BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
header = (byte *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
|
header = (byte *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
|
||||||
|
|
||||||
@ -1861,7 +1870,7 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled())
|
if (bIsRamEncryptionEnabled)
|
||||||
{
|
{
|
||||||
pCryptoInfo = crypto_open();
|
pCryptoInfo = crypto_open();
|
||||||
if (!pCryptoInfo)
|
if (!pCryptoInfo)
|
||||||
@ -1915,7 +1924,7 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN
|
|||||||
dwError = GetLastError();
|
dwError = GetLastError();
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
if (IsRamEncryptionEnabled() && pCryptoInfo)
|
if (bIsRamEncryptionEnabled && pCryptoInfo)
|
||||||
{
|
{
|
||||||
crypto_close(pCryptoInfo);
|
crypto_close(pCryptoInfo);
|
||||||
}
|
}
|
||||||
|
@ -5157,7 +5157,14 @@ static BOOL Dismount (HWND hwndDlg, int nDosDriveNo)
|
|||||||
WaitCursor ();
|
WaitCursor ();
|
||||||
|
|
||||||
if (nDosDriveNo == -2)
|
if (nDosDriveNo == -2)
|
||||||
|
{
|
||||||
nDosDriveNo = (char) (HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) - L'A');
|
nDosDriveNo = (char) (HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) - L'A');
|
||||||
|
if (nDosDriveNo < 0 || nDosDriveNo >= 26)
|
||||||
|
{
|
||||||
|
NormalCursor ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bCloseDismountedWindows)
|
if (bCloseDismountedWindows)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user