VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Format.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-07-14 15:41:09 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 22:21:27 (GMT)
commitc220db01281564bf5b50575ee7e24b38e45f5050 (patch)
tree5e66aa935ec029ca2bac6fa282f4c18710fc2d0d /src/Common/Format.c
parentc01f392a7ba1d5cdd4aa182eeb273cf41717d94f (diff)
downloadVeraCrypt-c220db01281564bf5b50575ee7e24b38e45f5050.zip
VeraCrypt-c220db01281564bf5b50575ee7e24b38e45f5050.tar.gz
Static Code Analysis : Generalize the use of Safe String functions. Add some NULL pointer checks. Avoid false-positive detection in AppendMenu (MF_SEPARATOR) calls by setting the last parameter to "" instead of NULL.
Diffstat (limited to 'src/Common/Format.c')
-rw-r--r--src/Common/Format.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Common/Format.c b/src/Common/Format.c
index 25f20ac..ad6be02 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -29,6 +29,8 @@
#include "Format/FormatCom.h"
#include "Format/Tcformat.h"
+#include <Strsafe.h>
+
int FormatWriteBufferSize = 1024 * 1024;
static uint32 FormatSectorSize = 0;
@@ -129,8 +131,8 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
if (volParams->bDevice)
{
- strcpy ((char *)deviceName, volParams->volumePath);
- ToUNICODE ((char *)deviceName);
+ StringCbCopyA ((char *)deviceName, sizeof(deviceName), volParams->volumePath);
+ ToUNICODE ((char *)deviceName, sizeof(deviceName));
driveLetter = GetDiskDeviceDriveLetter (deviceName);
}
@@ -170,7 +172,7 @@ begin_format:
DWORD dwResult;
int nPass;
- if (FakeDosNameForDevice (volParams->volumePath, dosDev, devName, FALSE) != 0)
+ if (FakeDosNameForDevice (volParams->volumePath, dosDev, sizeof(dosDev), devName, sizeof(devName), FALSE) != 0)
return ERR_OS_ERROR;
if (IsDeviceMounted (devName))
@@ -803,10 +805,10 @@ BOOL FormatNtfs (int driveNo, int clusterSize)
if (GetSystemDirectory (dllPath, MAX_PATH))
{
- strcat(dllPath, "\\fmifs.dll");
+ StringCbCatA(dllPath, sizeof(dllPath), "\\fmifs.dll");
}
else
- strcpy(dllPath, "C:\\Windows\\System32\\fmifs.dll");
+ StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\fmifs.dll");
hModule = LoadLibrary (dllPath);
@@ -819,7 +821,7 @@ BOOL FormatNtfs (int driveNo, int clusterSize)
return FALSE;
}
- wcscat (dir, L":\\");
+ StringCbCatW (dir, sizeof(dir), L":\\");
FormatExResult = FALSE;