mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 02:58:02 -06:00
Windows:Fix various issues and warnings reported by static code analysis tool Coverity.
This commit is contained in:
@@ -691,7 +691,7 @@ namespace VeraCrypt
|
||||
GetSystemDriveConfiguration();
|
||||
|
||||
ProbeRealDriveSizeRequest request;
|
||||
StringCbCopyW (request.DeviceName, sizeof (request.DeviceName), DriveConfig.DrivePartition.DevicePath.c_str());
|
||||
StringCchCopyW (request.DeviceName, ARRAYSIZE (request.DeviceName), DriveConfig.DrivePartition.DevicePath.c_str());
|
||||
|
||||
CallDriver (TC_IOCTL_PROBE_REAL_DRIVE_SIZE, &request, sizeof (request), &request, sizeof (request));
|
||||
DriveConfig.DrivePartition.Info.PartitionLength = request.RealDriveSize;
|
||||
@@ -720,7 +720,7 @@ namespace VeraCrypt
|
||||
partPath << L"\\Device\\Harddisk" << driveNumber << L"\\Partition" << partNumber;
|
||||
|
||||
DISK_PARTITION_INFO_STRUCT diskPartInfo = {0};
|
||||
StringCbCopyW (diskPartInfo.deviceName, sizeof (diskPartInfo.deviceName), partPath.str().c_str());
|
||||
StringCchCopyW (diskPartInfo.deviceName, ARRAYSIZE (diskPartInfo.deviceName), partPath.str().c_str());
|
||||
|
||||
try
|
||||
{
|
||||
@@ -833,7 +833,7 @@ namespace VeraCrypt
|
||||
memset (&openTestStruct, 0, sizeof (openTestStruct));
|
||||
DWORD dwResult;
|
||||
|
||||
StringCbCopyW (&openTestStruct.wszFileName[0], sizeof(openTestStruct.wszFileName),devicePath);
|
||||
StringCchCopyW (&openTestStruct.wszFileName[0], ARRAYSIZE(openTestStruct.wszFileName),devicePath);
|
||||
|
||||
openTestStruct.bDetectTCBootLoader = TRUE;
|
||||
|
||||
@@ -935,7 +935,7 @@ namespace VeraCrypt
|
||||
bool BootEncryption::SystemDriveIsDynamic ()
|
||||
{
|
||||
GetSystemDriveConfigurationRequest request;
|
||||
StringCbCopyW (request.DevicePath, sizeof (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str());
|
||||
StringCchCopyW (request.DevicePath, ARRAYSIZE (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str());
|
||||
|
||||
CallDriver (TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG, &request, sizeof (request), &request, sizeof (request));
|
||||
return request.DriveIsDynamic ? true : false;
|
||||
@@ -1240,7 +1240,7 @@ namespace VeraCrypt
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
|
||||
GetSystemDriveConfigurationRequest request;
|
||||
StringCbCopyW (request.DevicePath, sizeof (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str());
|
||||
StringCchCopyW (request.DevicePath, ARRAYSIZE (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str());
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1973,7 +1973,7 @@ namespace VeraCrypt
|
||||
DWORD size = (DWORD) (sizeof (regKeyBuf) - strSize);
|
||||
|
||||
// SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly
|
||||
StringCbCopyA ((char *) regKeyBuf, sizeof(regKeyBuf), filter.c_str());
|
||||
StringCchCopyA ((char *) regKeyBuf, ARRAYSIZE(regKeyBuf), filter.c_str());
|
||||
|
||||
if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, regKeyBuf + strSize, &size) != ERROR_SUCCESS)
|
||||
size = 1;
|
||||
@@ -2115,6 +2115,7 @@ namespace VeraCrypt
|
||||
SC_HANDLE service = OpenService (scm, TC_SYSTEM_FAVORITES_SERVICE_NAME, SERVICE_ALL_ACCESS);
|
||||
if (service)
|
||||
{
|
||||
finally_do_arg (SC_HANDLE, service, { CloseServiceHandle (finally_arg); });
|
||||
// ensure that its parameters are correct
|
||||
throw_sys_if (!ChangeServiceConfig (service,
|
||||
SERVICE_WIN32_OWN_PROCESS,
|
||||
@@ -2585,23 +2586,26 @@ namespace VeraCrypt
|
||||
if (!systemPartitionOnly)
|
||||
{
|
||||
DISK_GEOMETRY geometry = GetDriveGeometry (config.DriveNumber);
|
||||
Buffer sector (geometry.BytesPerSector);
|
||||
|
||||
Device device (config.DevicePath);
|
||||
device.CheckOpened (SRC_POS);
|
||||
|
||||
try
|
||||
if ((geometry.BytesPerSector > 0) && (geometry.BytesPerSector < TC_MAX_VOLUME_SECTOR_SIZE))
|
||||
{
|
||||
device.SeekAt (config.DrivePartition.Info.PartitionLength.QuadPart - geometry.BytesPerSector);
|
||||
device.Read (sector.Ptr(), (DWORD) sector.Size());
|
||||
}
|
||||
catch (SystemException &e)
|
||||
{
|
||||
if (e.ErrorCode != ERROR_CRC)
|
||||
Buffer sector (geometry.BytesPerSector);
|
||||
|
||||
Device device (config.DevicePath);
|
||||
device.CheckOpened (SRC_POS);
|
||||
|
||||
try
|
||||
{
|
||||
e.Show (ParentWindow);
|
||||
Error ("WHOLE_DRIVE_ENCRYPTION_PREVENTED_BY_DRIVERS", ParentWindow);
|
||||
throw UserAbort (SRC_POS);
|
||||
device.SeekAt (config.DrivePartition.Info.PartitionLength.QuadPart - geometry.BytesPerSector);
|
||||
device.Read (sector.Ptr(), (DWORD) sector.Size());
|
||||
}
|
||||
catch (SystemException &e)
|
||||
{
|
||||
if (e.ErrorCode != ERROR_CRC)
|
||||
{
|
||||
e.Show (ParentWindow);
|
||||
Error ("WHOLE_DRIVE_ENCRYPTION_PREVENTED_BY_DRIVERS", ParentWindow);
|
||||
throw UserAbort (SRC_POS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2641,7 +2645,7 @@ namespace VeraCrypt
|
||||
void BootEncryption::RestrictPagingFilesToSystemPartition ()
|
||||
{
|
||||
wchar_t pagingFiles[128] = {0};
|
||||
StringCbCopyW (pagingFiles, sizeof(pagingFiles), L"X:\\pagefile.sys 0 0");
|
||||
StringCchCopyW (pagingFiles, ARRAYSIZE(pagingFiles), L"X:\\pagefile.sys 0 0");
|
||||
pagingFiles[0] = GetWindowsDirectory()[0];
|
||||
|
||||
throw_sys_if (!WriteLocalMachineRegistryMultiString (L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", pagingFiles, (DWORD) (wcslen (pagingFiles) + 2) * sizeof (wchar_t)));
|
||||
|
||||
@@ -173,7 +173,7 @@ int GetArgumentValue (wchar_t **lpszCommandLineArgs, int *nArgIdx,
|
||||
{
|
||||
/* Handles the case of space between parameter code
|
||||
and value */
|
||||
StringCbCopyW (lpszValue, nValueSize, lpszCommandLineArgs[*nArgIdx + 1]);
|
||||
StringCchCopyW (lpszValue, nValueSize, lpszCommandLineArgs[*nArgIdx + 1]);
|
||||
lpszValue[nValueSize - 1] = 0;
|
||||
(*nArgIdx)++;
|
||||
return HAS_ARGUMENT;
|
||||
|
||||
@@ -232,7 +232,7 @@ void DumpCombo (HWND hComboBox, int bClear)
|
||||
if (szTmp[0] != 0)
|
||||
{
|
||||
wchar_t q[MAX_PATH * 2] = { 0 };
|
||||
XmlQuoteTextW (szTmp, q, sizeof (q));
|
||||
XmlQuoteTextW (szTmp, q, ARRAYSIZE (q));
|
||||
|
||||
fwprintf (f, L"\n\t\t<volume>%s</volume>", q);
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ DWORD handleWin32Error (HWND hwndDlg, const char* srcPos)
|
||||
pszDesc = (wchar_t*) lpMsgBuf;
|
||||
else
|
||||
{
|
||||
StringCbPrintfW (szErrorValue, sizeof (szErrorValue), L"Error 0x%.8X", dwError);
|
||||
StringCchPrintfW (szErrorValue, ARRAYSIZE (szErrorValue), L"Error 0x%.8X", dwError);
|
||||
pszDesc = szErrorValue;
|
||||
}
|
||||
|
||||
@@ -853,7 +853,7 @@ std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::w
|
||||
SelectObject (hdc, (HGDIOBJ) hFont);
|
||||
|
||||
wchar_t pathBuf[TC_MAX_PATH];
|
||||
StringCbCopyW (pathBuf, sizeof (pathBuf), path.c_str());
|
||||
StringCchCopyW (pathBuf, ARRAYSIZE (pathBuf), path.c_str());
|
||||
|
||||
if (DrawText (hdc, pathBuf, (int) path.size(), &rect, DT_CALCRECT | DT_MODIFYSTRING | DT_PATH_ELLIPSIS | DT_SINGLELINE) != 0)
|
||||
newPath = pathBuf;
|
||||
@@ -4898,6 +4898,8 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
|
||||
|
||||
if (QueryPerformanceFrequency (&benchmarkPerformanceFrequency) == 0)
|
||||
{
|
||||
if (ci)
|
||||
crypto_close (ci);
|
||||
MessageBoxW (hwndDlg, GetString ("ERR_PERF_COUNTER"), lpszTitle, ICON_HAND);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -4905,6 +4907,8 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
|
||||
lpTestBuffer = (BYTE *) malloc(benchmarkBufferSize - (benchmarkBufferSize % 16));
|
||||
if (lpTestBuffer == NULL)
|
||||
{
|
||||
if (ci)
|
||||
crypto_close (ci);
|
||||
MessageBoxW (hwndDlg, GetString ("ERR_MEM_ALLOC"), lpszTitle, ICON_HAND);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -8132,7 +8136,7 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile,
|
||||
{
|
||||
dst = CreateFile (destinationFile,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, bAppend ? OPEN_EXISTING : CREATE_ALWAYS, 0, NULL);
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
dwLastError = GetLastError();
|
||||
if (dst == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -9372,7 +9376,7 @@ void RestoreDefaultKeyFilesParam (void)
|
||||
KeyFileRemoveAll (&FirstKeyFile);
|
||||
if (defaultKeyFilesParam.FirstKeyFile != NULL)
|
||||
{
|
||||
FirstKeyFile = KeyFileCloneAll (defaultKeyFilesParam.FirstKeyFile);
|
||||
KeyFileCloneAll (defaultKeyFilesParam.FirstKeyFile, &FirstKeyFile);
|
||||
KeyFilesEnable = defaultKeyFilesParam.EnableKeyFiles;
|
||||
}
|
||||
else
|
||||
@@ -11295,7 +11299,7 @@ BOOL IsApplicationInstalled (const wchar_t *appName, BOOL b32bitApp)
|
||||
const wchar_t *uninstallRegName = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
|
||||
BOOL installed = FALSE;
|
||||
HKEY unistallKey;
|
||||
LONG res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, uninstallRegName, 0, KEY_READ | b32bitApp? KEY_WOW64_32KEY: KEY_WOW64_64KEY, &unistallKey);
|
||||
LONG res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, uninstallRegName, 0, KEY_READ | (b32bitApp? KEY_WOW64_32KEY: KEY_WOW64_64KEY), &unistallKey);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
SetLastError (res);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace VeraCrypt
|
||||
void Show (HWND parent) const
|
||||
{
|
||||
char szErrCode[16];
|
||||
StringCbPrintfA (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
|
||||
StringCchPrintfA (szErrCode, ARRAYSIZE(szErrCode), "0x%.8X", LastError);
|
||||
string msgBody = "The Random Generator initialization failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
||||
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace VeraCrypt
|
||||
void Show (HWND parent) const
|
||||
{
|
||||
char szErrCode[16];
|
||||
StringCbPrintfA (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
|
||||
StringCchPrintfA (szErrCode, ARRAYSIZE(szErrCode), "0x%.8X", LastError);
|
||||
string msgBody = "Windows Crypto API failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
||||
MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
|
||||
|
||||
if (volParams->bDevice)
|
||||
{
|
||||
StringCbCopyW (deviceName, sizeof(deviceName), volParams->volumePath);
|
||||
StringCchCopyW (deviceName, ARRAYSIZE(deviceName), volParams->volumePath);
|
||||
|
||||
driveLetter = GetDiskDeviceDriveLetter (deviceName);
|
||||
}
|
||||
@@ -874,10 +874,10 @@ BOOL FormatFs (int driveNo, int clusterSize, int fsType)
|
||||
switch (fsType)
|
||||
{
|
||||
case FILESYS_NTFS:
|
||||
StringCbCopyW (szFsFormat, sizeof (szFsFormat),L"NTFS");
|
||||
StringCchCopyW (szFsFormat, ARRAYSIZE (szFsFormat),L"NTFS");
|
||||
break;
|
||||
case FILESYS_EXFAT:
|
||||
StringCbCopyW (szFsFormat, sizeof (szFsFormat),L"EXFAT");
|
||||
StringCchCopyW (szFsFormat, ARRAYSIZE (szFsFormat),L"EXFAT");
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
@@ -886,10 +886,10 @@ BOOL FormatFs (int driveNo, int clusterSize, int fsType)
|
||||
|
||||
if (GetSystemDirectory (dllPath, MAX_PATH))
|
||||
{
|
||||
StringCbCatW(dllPath, sizeof(dllPath), L"\\fmifs.dll");
|
||||
StringCchCatW(dllPath, ARRAYSIZE(dllPath), L"\\fmifs.dll");
|
||||
}
|
||||
else
|
||||
StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\fmifs.dll");
|
||||
StringCchCopyW(dllPath, ARRAYSIZE(dllPath), L"C:\\Windows\\System32\\fmifs.dll");
|
||||
|
||||
hModule = LoadLibrary (dllPath);
|
||||
|
||||
@@ -902,7 +902,7 @@ BOOL FormatFs (int driveNo, int clusterSize, int fsType)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
StringCbCatW (dir, sizeof(dir), L":\\");
|
||||
StringCchCatW (dir, ARRAYSIZE(dir), L":\\");
|
||||
|
||||
FormatExError = TRUE;
|
||||
|
||||
|
||||
@@ -119,20 +119,26 @@ KeyFile *KeyFileClone (KeyFile *keyFile)
|
||||
}
|
||||
|
||||
|
||||
KeyFile *KeyFileCloneAll (KeyFile *firstKeyFile)
|
||||
void KeyFileCloneAll (KeyFile *firstKeyFile, KeyFile **outputKeyFile)
|
||||
{
|
||||
KeyFile *cloneFirstKeyFile = KeyFileClone (firstKeyFile);
|
||||
KeyFile *kf;
|
||||
|
||||
if (firstKeyFile == NULL) return NULL;
|
||||
kf = firstKeyFile->Next;
|
||||
while (kf != NULL)
|
||||
if (outputKeyFile)
|
||||
{
|
||||
KeyFileAdd (cloneFirstKeyFile, KeyFileClone (kf));
|
||||
kf = kf->Next;
|
||||
}
|
||||
KeyFile *cloneFirstKeyFile = KeyFileClone (firstKeyFile);
|
||||
KeyFile *kf;
|
||||
|
||||
return cloneFirstKeyFile;
|
||||
KeyFileRemoveAll (outputKeyFile);
|
||||
if (firstKeyFile)
|
||||
{
|
||||
kf = firstKeyFile->Next;
|
||||
while (kf != NULL)
|
||||
{
|
||||
KeyFileAdd (cloneFirstKeyFile, KeyFileClone (kf));
|
||||
kf = kf->Next;
|
||||
}
|
||||
|
||||
*outputKeyFile = cloneFirstKeyFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -451,7 +457,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
||||
param = (KeyFilesDlgParam *) lParam;
|
||||
origParam = *(KeyFilesDlgParam *) lParam;
|
||||
|
||||
param->FirstKeyFile = KeyFileCloneAll (param->FirstKeyFile);
|
||||
KeyFileCloneAll (param->FirstKeyFile, ¶m->FirstKeyFile);
|
||||
|
||||
LocalizeDialog (hwndDlg, "IDD_KEYFILES");
|
||||
DragAcceptFiles (hwndDlg, TRUE);
|
||||
@@ -637,7 +643,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
||||
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
|
||||
if (kf)
|
||||
{
|
||||
DragQueryFile (hdrop, i++, kf->FileName, sizeof (kf->FileName));
|
||||
DragQueryFile (hdrop, i++, kf->FileName, ARRAYSIZE (kf->FileName));
|
||||
param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
|
||||
LoadKeyList (hwndDlg, param->FirstKeyFile);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ typedef struct
|
||||
KeyFile *KeyFileAdd (KeyFile *firstKeyFile, KeyFile *keyFile);
|
||||
void KeyFileRemoveAll (KeyFile **firstKeyFile);
|
||||
KeyFile *KeyFileClone (KeyFile *keyFile);
|
||||
KeyFile *KeyFileCloneAll (KeyFile *firstKeyFile);
|
||||
void KeyFileCloneAll (KeyFile *firstKeyFile, KeyFile **outputKeyFile);
|
||||
BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFilem, const wchar_t* volumeFileName);
|
||||
|
||||
BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
@@ -43,8 +43,8 @@ void VerifyPasswordAndUpdate (HWND hwndDlg, HWND hButton, HWND hPassword,
|
||||
|
||||
UNREFERENCED_PARAMETER (hwndDlg); /* Remove warning */
|
||||
|
||||
GetWindowText (hPassword, szTmp1, sizeof (szTmp1));
|
||||
GetWindowText (hVerify, szTmp2, sizeof (szTmp2));
|
||||
GetWindowText (hPassword, szTmp1, ARRAYSIZE (szTmp1));
|
||||
GetWindowText (hVerify, szTmp2, ARRAYSIZE (szTmp2));
|
||||
|
||||
utf8Len1 = WideCharToMultiByte (CP_UTF8, 0, szTmp1, -1, szTmp1Utf8, MAX_PASSWORD + 1, NULL, NULL);
|
||||
utf8Len2 = WideCharToMultiByte (CP_UTF8, 0, szTmp2, -1, szTmp2Utf8, MAX_PASSWORD + 1, NULL, NULL);
|
||||
|
||||
@@ -78,23 +78,23 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
|
||||
double perc = (double) (100.0 * (bProgressBarReverse ? ((double) (TotalSize - byteOffset)) : ((double) byteOffset)) / (TotalSize == 0 ? 0.0001 : ((double) TotalSize)));
|
||||
|
||||
if (perc > 99.999999999)
|
||||
StringCbCopyW (text,sizeof(text), GetString ("PROCESSED_PORTION_100_PERCENT"));
|
||||
StringCchCopyW (text,ARRAYSIZE(text), GetString ("PROCESSED_PORTION_100_PERCENT"));
|
||||
else
|
||||
StringCbPrintfW (text, sizeof text, GetString ("PROCESSED_PORTION_X_PERCENT"), perc);
|
||||
StringCchPrintfW (text, ARRAYSIZE (text), GetString ("PROCESSED_PORTION_X_PERCENT"), perc);
|
||||
|
||||
StringCbCatW (text, sizeof(speed), L" ");
|
||||
StringCchCatW (text, ARRAYSIZE(text), L" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
GetSizeString (bytesDone, text, sizeof(text));
|
||||
if (bytesDone < (unsigned __int64) BYTES_PER_MB * 1000000)
|
||||
StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB"));
|
||||
StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB"));
|
||||
else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 1000000)
|
||||
StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB"));
|
||||
StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB"));
|
||||
else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 1000000)
|
||||
StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB"));
|
||||
StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB"));
|
||||
else
|
||||
StringCbPrintfW(text, sizeof(text), L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB"));
|
||||
StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB"));
|
||||
}
|
||||
|
||||
SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text);
|
||||
@@ -102,7 +102,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
|
||||
if (!bShowStatus)
|
||||
{
|
||||
GetSpeedString (bRWThroughput ? bytesPerSec*2 : bytesPerSec, speed, sizeof(speed));
|
||||
StringCbCatW (speed, sizeof(speed), L" ");
|
||||
StringCchCatW (speed, ARRAYSIZE(speed), L" ");
|
||||
SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), speed);
|
||||
}
|
||||
|
||||
@@ -111,15 +111,15 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
|
||||
int64 sec = (int64) ((bProgressBarReverse ? byteOffset : (TotalSize - byteOffset)) / (bytesPerSec == 0 ? 0.001 : bytesPerSec));
|
||||
|
||||
if (bytesPerSec == 0 || sec > 60 * 60 * 24 * 999)
|
||||
StringCbPrintfW (text, sizeof(text), L"%s ", GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE"));
|
||||
StringCchPrintfW (text, ARRAYSIZE(text), L"%s ", GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE"));
|
||||
else if (sec >= 60 * 60 * 24 * 2)
|
||||
StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec / (60 * 24 * 60), days);
|
||||
StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec / (60 * 24 * 60), days);
|
||||
else if (sec >= 120 * 60)
|
||||
StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec / (60 * 60), hours);
|
||||
StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec / (60 * 60), hours);
|
||||
else if (sec >= 120)
|
||||
StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec / 60, minutes);
|
||||
StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec / 60, minutes);
|
||||
else
|
||||
StringCbPrintfW (text, sizeof(text), L"%I64d %s ", sec, seconds);
|
||||
StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec, seconds);
|
||||
|
||||
SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text);
|
||||
}
|
||||
|
||||
@@ -671,10 +671,10 @@ BOOL SlowPoll (void)
|
||||
wchar_t dllPath[MAX_PATH];
|
||||
if (GetSystemDirectory (dllPath, MAX_PATH))
|
||||
{
|
||||
StringCbCatW(dllPath, sizeof(dllPath), L"\\NETAPI32.DLL");
|
||||
StringCchCatW(dllPath, ARRAYSIZE(dllPath), L"\\NETAPI32.DLL");
|
||||
}
|
||||
else
|
||||
StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\NETAPI32.DLL");
|
||||
StringCchCopyW(dllPath, ARRAYSIZE(dllPath), L"C:\\Windows\\System32\\NETAPI32.DLL");
|
||||
|
||||
hNetAPI32 = LoadLibrary (dllPath);
|
||||
if (hNetAPI32 != NULL)
|
||||
@@ -725,7 +725,7 @@ BOOL SlowPoll (void)
|
||||
wchar_t szDevice[24];
|
||||
|
||||
/* Check whether we can access this device */
|
||||
StringCbPrintfW (szDevice, sizeof(szDevice), L"\\\\.\\PhysicalDrive%d", nDrive);
|
||||
StringCchPrintfW (szDevice, ARRAYSIZE(szDevice), L"\\\\.\\PhysicalDrive%d", nDrive);
|
||||
hDevice = CreateFile (szDevice, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hDevice == INVALID_HANDLE_VALUE)
|
||||
|
||||
@@ -1022,16 +1022,16 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea,
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
wchar_t tmp2[8] = {0};
|
||||
StringCbPrintfW (tmp2, sizeof(tmp2), L"%02X", (int) (unsigned char) keyInfo.master_keydata[i + primaryKeyOffset]);
|
||||
StringCbCatW (MasterKeyGUIView, sizeof(MasterKeyGUIView), tmp2);
|
||||
StringCchPrintfW (tmp2, ARRAYSIZE(tmp2), L"%02X", (int) (unsigned char) keyInfo.master_keydata[i + primaryKeyOffset]);
|
||||
StringCchCatW (MasterKeyGUIView, ARRAYSIZE(MasterKeyGUIView), tmp2);
|
||||
}
|
||||
|
||||
HeaderKeyGUIView[0] = 0;
|
||||
for (i = 0; i < NBR_KEY_BYTES_TO_DISPLAY; i++)
|
||||
{
|
||||
wchar_t tmp2[8];
|
||||
StringCbPrintfW (tmp2, sizeof(tmp2), L"%02X", (int) (unsigned char) dk[primaryKeyOffset + i]);
|
||||
StringCbCatW (HeaderKeyGUIView, sizeof(HeaderKeyGUIView), tmp2);
|
||||
StringCchPrintfW (tmp2, ARRAYSIZE(tmp2), L"%02X", (int) (unsigned char) dk[primaryKeyOffset + i]);
|
||||
StringCchCatW (HeaderKeyGUIView, ARRAYSIZE(HeaderKeyGUIView), tmp2);
|
||||
}
|
||||
|
||||
if (dots3)
|
||||
|
||||
@@ -568,6 +568,7 @@ void WhirlpoolTransform(uint64 *digest, const uint64 *block)
|
||||
uint64 s[8]; // the cipher state
|
||||
uint64 k[8]; // the round key
|
||||
int r;
|
||||
uint64 w0 = 0, w1 = 0, w2 = 0, w3 = 0, w4 = 0, w5 = 0, w6 = 0, w7 = 0; // temporary storage
|
||||
|
||||
// Compute and apply K^0 to the cipher state
|
||||
// Also apply part of the Miyaguchi-Preneel compression function
|
||||
@@ -627,7 +628,6 @@ void WhirlpoolTransform(uint64 *digest, const uint64 *block)
|
||||
r=0;
|
||||
while (1)
|
||||
{
|
||||
uint64 w0, w1, w2, w3, w4, w5, w6, w7; // temporary storage
|
||||
uint32 t;
|
||||
|
||||
KSL(0, 4, 3, 2, 1, 0)
|
||||
|
||||
@@ -305,7 +305,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
|
||||
SetDlgItemText(hwndDlg, IDC_BOX_STATUS, L"IMPORTANT: Move your mouse as randomly as possible within this window. The longer you move it, the better. This significantly increases the cryptographic strength of the encryption keys. Then click 'Continue' to expand the volume.");
|
||||
}
|
||||
|
||||
SendMessage (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS), BM_SETCHECK, showRandPool ? BST_CHECKED : BST_UNCHECKED, 0);
|
||||
SendMessage (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS), BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR);
|
||||
SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel);
|
||||
SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0);
|
||||
|
||||
@@ -759,7 +759,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
|
||||
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
|
||||
if (kf)
|
||||
{
|
||||
DragQueryFile (hdrop, i++, kf->FileName, sizeof (kf->FileName));
|
||||
DragQueryFile (hdrop, i++, kf->FileName, ARRAYSIZE (kf->FileName));
|
||||
FirstKeyFile = KeyFileAdd (FirstKeyFile, kf);
|
||||
KeyFilesEnable = TRUE;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
|
||||
|
||||
dataAreaSize = GetVolumeDataAreaSize (volParams->hiddenVol, deviceSize);
|
||||
|
||||
StringCbCopyW (deviceName, sizeof(deviceName), volParams->volumePath);
|
||||
StringCchCopyW (deviceName, ARRAYSIZE(deviceName), volParams->volumePath);
|
||||
|
||||
driveLetter = GetDiskDeviceDriveLetter (deviceName);
|
||||
|
||||
@@ -1284,6 +1284,16 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
|
||||
goto closing_seq;
|
||||
}
|
||||
|
||||
if ( (driveGeometry.BytesPerSector == 0)
|
||||
|| (driveGeometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE)
|
||||
|| (driveGeometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0)
|
||||
)
|
||||
{
|
||||
Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg);
|
||||
nStatus = ERR_DONT_REPORT;
|
||||
goto closing_seq;
|
||||
}
|
||||
|
||||
sectorSize = driveGeometry.BytesPerSector;
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -389,7 +389,12 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
|
||||
|
||||
DisplayHotkeyList(hwndDlg);
|
||||
|
||||
SetTimer (hwndDlg, 0xfe, 10, NULL);
|
||||
if (SetTimer (hwndDlg, 0xfe, 10, NULL) == 0)
|
||||
{
|
||||
Error ("CANNOT_SET_TIMER", MainDlg);
|
||||
EndDialog (hwndDlg, IDCANCEL);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,8 +280,9 @@ extern "C" int UacChangePwd (wchar_t *lpszVolume, Password *oldPassword, int old
|
||||
|
||||
if (ComGetInstance (hwndDlg, &tc))
|
||||
{
|
||||
CComBSTR bstrVolume (lpszVolume);
|
||||
WaitCursor ();
|
||||
r = tc->ChangePasswordEx3 (lpszVolume, oldPassword, old_pkcs5, old_pim, truecryptMode, newPassword, pkcs5, pim, wipePassCount, (LONG_PTR) hwndDlg);
|
||||
r = tc->ChangePasswordEx3 (bstrVolume, oldPassword, old_pkcs5, old_pim, truecryptMode, newPassword, pkcs5, pim, wipePassCount, (LONG_PTR) hwndDlg);
|
||||
NormalCursor ();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1552,7 +1552,15 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
|
||||
GetSizeString (GetSysEncDeviceSize(TRUE), szTmpW, sizeof(szTmpW));
|
||||
ListSubItemSet (hTree, listItem.iItem, 2, szTmpW);
|
||||
|
||||
EAGetName (szTmp, propSysEnc.ea, 1);
|
||||
if (propSysEnc.ea >= EAGetFirst() && propSysEnc.ea <= EAGetCount())
|
||||
{
|
||||
EAGetName (szTmp, propSysEnc.ea, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
szTmp[0] = L'?';
|
||||
szTmp[1] = 0;
|
||||
}
|
||||
listItem.iSubItem = 3;
|
||||
ListView_SetItem (hTree, &listItem);
|
||||
|
||||
@@ -3002,7 +3010,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
||||
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
|
||||
if (kf)
|
||||
{
|
||||
DragQueryFile (hdrop, i++, kf->FileName, sizeof (kf->FileName));
|
||||
DragQueryFile (hdrop, i++, kf->FileName, ARRAYSIZE (kf->FileName));
|
||||
FirstKeyFile = KeyFileAdd (FirstKeyFile, kf);
|
||||
KeyFilesEnable = TRUE;
|
||||
}
|
||||
@@ -3744,7 +3752,7 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
|
||||
// Encryption algorithm
|
||||
ListItemAdd (list, i, GetString ("ENCRYPTION_ALGORITHM"));
|
||||
|
||||
if (prop.ea == 0 || prop.ea > EAGetCount ())
|
||||
if (prop.ea < EAGetFirst() || prop.ea > EAGetCount ())
|
||||
{
|
||||
ListSubItemSet (list, i, 1, L"?");
|
||||
return 1;
|
||||
@@ -5849,13 +5857,13 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate)
|
||||
LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
|
||||
NormalCursor ();
|
||||
|
||||
if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
|
||||
if (selDrive != ((wchar_t) 0xFFFF) && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
|
||||
{
|
||||
nSelectedDriveIndex = -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (selDrive != -1)
|
||||
if (selDrive != ((wchar_t) 0xFFFF))
|
||||
SelectItem (GetDlgItem (MainDlg, IDC_DRIVELIST),selDrive);
|
||||
}
|
||||
|
||||
@@ -5900,12 +5908,12 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate)
|
||||
|
||||
RecentBootEncStatus = newBootEncStatus;
|
||||
|
||||
if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
|
||||
if (selDrive != ((wchar_t) 0xFFFF) && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
|
||||
{
|
||||
nSelectedDriveIndex = -1;
|
||||
}
|
||||
|
||||
if (selDrive != -1)
|
||||
if (selDrive != ((wchar_t) 0xFFFF))
|
||||
{
|
||||
SelectItem (GetDlgItem (MainDlg, IDC_DRIVELIST),selDrive);
|
||||
}
|
||||
@@ -6069,9 +6077,9 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam)
|
||||
{
|
||||
pt.x += 2 + ::GetSystemMetrics(SM_CXICON);
|
||||
pt.y += 2;
|
||||
ClientToScreen (hList, &pt);
|
||||
mPos = MAKELONG (pt.x, pt.y);
|
||||
}
|
||||
ClientToScreen (hList, &pt);
|
||||
mPos = MAKELONG (pt.x, pt.y);
|
||||
}
|
||||
|
||||
menuItem = TrackPopupMenu (popup,
|
||||
@@ -6277,8 +6285,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
if (FirstCmdKeyFile)
|
||||
{
|
||||
KeyFilesEnable = defaultKeyFilesParam.EnableKeyFiles = TRUE;
|
||||
FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
|
||||
defaultKeyFilesParam.FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
|
||||
KeyFileCloneAll (FirstCmdKeyFile, &FirstKeyFile);
|
||||
KeyFileCloneAll (FirstCmdKeyFile, &defaultKeyFilesParam.FirstKeyFile);
|
||||
}
|
||||
|
||||
if (!MountAllDevices (hwndDlg, !Silent && !CmdVolumePasswordValid && IsPasswordCacheEmpty()))
|
||||
@@ -6291,8 +6299,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
if (FirstCmdKeyFile)
|
||||
{
|
||||
KeyFilesEnable = defaultKeyFilesParam.EnableKeyFiles = TRUE;
|
||||
FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
|
||||
defaultKeyFilesParam.FirstKeyFile = KeyFileCloneAll (FirstCmdKeyFile);
|
||||
KeyFileCloneAll (FirstCmdKeyFile, &FirstKeyFile);
|
||||
KeyFileCloneAll (FirstCmdKeyFile, &defaultKeyFilesParam.FirstKeyFile);
|
||||
}
|
||||
|
||||
if (!MountFavoriteVolumes (hwndDlg, FALSE, LogOn))
|
||||
@@ -6342,6 +6350,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
|
||||
if (FirstCmdKeyFile)
|
||||
{
|
||||
KeyFileRemoveAll (&FirstKeyFile);
|
||||
FirstKeyFile = FirstCmdKeyFile;
|
||||
KeyFilesEnable = TRUE;
|
||||
}
|
||||
@@ -7414,7 +7423,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
}
|
||||
else
|
||||
{
|
||||
GetVolumePath (hwndDlg, volPath, sizeof (volPath));
|
||||
GetVolumePath (hwndDlg, volPath, ARRAYSIZE (volPath));
|
||||
|
||||
WaitCursor ();
|
||||
|
||||
@@ -8018,7 +8027,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
HDROP hdrop = (HDROP) wParam;
|
||||
DragQueryFile (hdrop, 0, szFileName, sizeof szFileName);
|
||||
DragQueryFile (hdrop, 0, szFileName, ARRAYSIZE (szFileName));
|
||||
DragFinish (hdrop);
|
||||
|
||||
AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
|
||||
@@ -8173,7 +8182,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
bAuto = TRUE;
|
||||
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||
&i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (!_wcsicmp (szTmp, L"devices"))
|
||||
bAutoMountDevices = TRUE;
|
||||
@@ -8198,7 +8207,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
bCmdTryEmptyPasswordWhenKeyfileUsedValid = TRUE;
|
||||
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||
szTmp, sizeof (szTmp)))
|
||||
szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
|
||||
bCmdTryEmptyPasswordWhenKeyfileUsed = FALSE;
|
||||
@@ -8217,7 +8226,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
bIncludePimInCache = FALSE;
|
||||
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||
szTmp, sizeof (szTmp)))
|
||||
szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
|
||||
bCacheInDriver = FALSE;
|
||||
@@ -8242,7 +8251,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
case CommandDismount:
|
||||
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||
szDriveLetter, sizeof (szDriveLetter)))
|
||||
szDriveLetter, ARRAYSIZE (szDriveLetter)))
|
||||
{
|
||||
if ( (wcslen(szDriveLetter) == 1)
|
||||
|| (wcslen(szDriveLetter) == 2 && szDriveLetter[1] == L':')
|
||||
@@ -8272,14 +8281,14 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
|
||||
case OptionKeyfile:
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i,
|
||||
nNoCommandLineArgs, tmpPath, sizeof (tmpPath)))
|
||||
nNoCommandLineArgs, tmpPath, ARRAYSIZE (tmpPath)))
|
||||
{
|
||||
KeyFile *kf;
|
||||
RelativePath2Absolute (tmpPath);
|
||||
kf = (KeyFile *) malloc (sizeof (KeyFile));
|
||||
if (kf)
|
||||
{
|
||||
StringCbCopyW (kf->FileName, sizeof(kf->FileName), tmpPath);
|
||||
StringCchCopyW (kf->FileName, ARRAYSIZE(kf->FileName), tmpPath);
|
||||
FirstCmdKeyFile = KeyFileAdd (FirstCmdKeyFile, kf);
|
||||
}
|
||||
}
|
||||
@@ -8290,7 +8299,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
|
||||
case OptionLetter:
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||
szDriveLetter, sizeof (szDriveLetter)))
|
||||
szDriveLetter, ARRAYSIZE (szDriveLetter)))
|
||||
{
|
||||
if ( (wcslen(szDriveLetter) == 1)
|
||||
|| (wcslen(szDriveLetter) == 2 && szDriveLetter[1] == L':')
|
||||
@@ -8315,7 +8324,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
bHistory = bHistoryCmdLine = TRUE;
|
||||
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||
szTmp, sizeof (szTmp)))
|
||||
szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
|
||||
bHistory = FALSE;
|
||||
@@ -8331,7 +8340,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
{
|
||||
wchar_t szTmp[64] = {0};
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||
&i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (!_wcsicmp (szTmp, L"ro") || !_wcsicmp (szTmp, L"readonly"))
|
||||
mountOptions.ReadOnly = TRUE;
|
||||
@@ -8370,7 +8379,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
{
|
||||
wchar_t szTmp[MAX_PASSWORD + 1];
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||
szTmp, sizeof (szTmp)))
|
||||
szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (char*) CmdVolumePassword.Text, MAX_PASSWORD + 1, NULL, NULL);
|
||||
burn (szTmp, sizeof (szTmp));
|
||||
@@ -8389,7 +8398,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
|
||||
case OptionVolume:
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i,
|
||||
nNoCommandLineArgs, szFileName, sizeof (szFileName)))
|
||||
nNoCommandLineArgs, szFileName, ARRAYSIZE (szFileName)))
|
||||
{
|
||||
RelativePath2Absolute (szFileName);
|
||||
AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
|
||||
@@ -8404,7 +8413,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
wchar_t szTmp[32] = {0};
|
||||
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||
&i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (!_wcsicmp (szTmp, L"UAC")) // Used to indicate non-install elevation
|
||||
break;
|
||||
@@ -8433,7 +8442,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
break;
|
||||
|
||||
case OptionTokenLib:
|
||||
if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
|
||||
if (GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, SecurityTokenLibraryPath, ARRAYSIZE (SecurityTokenLibraryPath)) == HAS_ARGUMENT)
|
||||
InitSecurityTokenLibrary(hwndDlg);
|
||||
else
|
||||
AbortProcess ("COMMAND_LINE_ERROR");
|
||||
@@ -8454,7 +8463,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
{
|
||||
wchar_t szTmp[32] = {0};
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||
&i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
if (_wcsicmp(szTmp, L"sha512") == 0 || _wcsicmp(szTmp, L"sha-512") == 0)
|
||||
CmdVolumePkcs5 = SHA512;
|
||||
@@ -8480,7 +8489,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||
{
|
||||
wchar_t szTmp[32] = {0};
|
||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||
&i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)))
|
||||
{
|
||||
wchar_t* endPtr = NULL;
|
||||
CmdVolumePim = (int) wcstol(szTmp, &endPtr, 0);
|
||||
@@ -8870,6 +8879,17 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite,
|
||||
BOOL status = TRUE;
|
||||
int drive;
|
||||
drive = towupper (favorite.MountPoint[0]) - L'A';
|
||||
|
||||
if ((drive < MIN_MOUNTED_VOLUME_DRIVE_NUMBER) || (drive > MAX_MOUNTED_VOLUME_DRIVE_NUMBER))
|
||||
{
|
||||
if (!systemFavorites)
|
||||
Error ("DRIVE_LETTER_UNAVAILABLE", MainDlg);
|
||||
else if (ServiceMode && systemFavorites)
|
||||
{
|
||||
SystemFavoritesServiceLogError (wstring (L"The drive letter ") + (wchar_t) (drive + L'A') + wstring (L" used by favorite \"") + favorite.Path + L"\" is invalid.\nThis system favorite will not be mounted");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mountOptions.ReadOnly = favorite.ReadOnly || userForcedReadOnly;
|
||||
mountOptions.Removable = favorite.Removable;
|
||||
|
||||
@@ -176,7 +176,7 @@ static int CompressBuffer (char *out, char *in, int len)
|
||||
startupInfo.hStdError = hChildStdoutWrite;
|
||||
startupInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||
|
||||
StringCbCopyW (szGzipCmd, sizeof (szGzipCmd), L"gzip --best");
|
||||
StringCchCopyW (szGzipCmd, ARRAYSIZE (szGzipCmd), L"gzip --best");
|
||||
if (!CreateProcess (NULL, szGzipCmd, NULL, NULL, TRUE, 0, NULL, NULL, &startupInfo, &procInfo))
|
||||
{
|
||||
PkgError (L"Error: Cannot run gzip.\n\nBefore you can create a self-extracting VeraCrypt package, you need to have the open-source 'gzip' compression tool placed in any directory in the search path for executable files (for example, in 'C:\\Windows\\').\n\nNote: gzip can be freely downloaded e.g. from www.gzip.org");
|
||||
@@ -256,8 +256,8 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir)
|
||||
|
||||
GetModuleFileName (NULL, inputFile, ARRAYSIZE (inputFile));
|
||||
|
||||
StringCbCopyW (outputFile, sizeof(outputFile), szDestDir);
|
||||
StringCbCatW (outputFile, sizeof(outputFile), OutputPackageFile);
|
||||
StringCchCopyW (outputFile, ARRAYSIZE(outputFile), szDestDir);
|
||||
StringCchCatW (outputFile, ARRAYSIZE(outputFile), OutputPackageFile);
|
||||
|
||||
// Clone 'VeraCrypt Setup.exe' to create the base of the new self-extracting archive
|
||||
|
||||
@@ -378,6 +378,16 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir)
|
||||
|
||||
// Compress all the files and meta data in the buffer to create a solid archive
|
||||
|
||||
// Test to make Coverity happy. It will always be false
|
||||
if (uncompressedDataLen >= (INT_MAX - 524288))
|
||||
{
|
||||
if (_wremove (outputFile))
|
||||
PkgError (L"Cannot allocate memory for compressed data.\nFailed also to delete package file");
|
||||
else
|
||||
PkgError (L"Cannot allocate memory for compressed data");
|
||||
goto err;
|
||||
}
|
||||
|
||||
compressedBuffer = malloc (uncompressedDataLen + 524288); // + 512K reserve
|
||||
if (compressedBuffer == NULL)
|
||||
{
|
||||
@@ -745,8 +755,8 @@ void __cdecl ExtractAllFilesThread (void *hwndDlg)
|
||||
|
||||
// Filename
|
||||
StringCchCopyNW (fileName, ARRAYSIZE(fileName), Decompressed_Files[fileNo].fileName, Decompressed_Files[fileNo].fileNameLength);
|
||||
StringCbCopyW (filePath, sizeof(filePath), DestExtractPath);
|
||||
StringCbCatW (filePath, sizeof(filePath), fileName);
|
||||
StringCchCopyW (filePath, ARRAYSIZE(filePath), DestExtractPath);
|
||||
StringCchCatW (filePath, ARRAYSIZE(filePath), fileName);
|
||||
|
||||
StatusMessageParam (hwndDlg, "EXTRACTING_VERB", filePath);
|
||||
|
||||
|
||||
@@ -712,7 +712,7 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
|
||||
StringCbCatW (szDir, sizeof(szDir), L"Drivers\\");
|
||||
}
|
||||
else if (*szFiles[i] == L'W')
|
||||
GetWindowsDirectory (szDir, sizeof (szDir));
|
||||
GetWindowsDirectory (szDir, ARRAYSIZE (szDir));
|
||||
|
||||
if (*szFiles[i] == L'I')
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user