VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-07-09 05:38:35 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 23:20:45 +0100
commit9d027b02b9723493f66b94bba648e20d48e73b6f (patch)
tree52d5d04929fe83fdea01ab0ff1ea3754b6be4efd /src
parent899a22b840316d54a9563726e78f7a201a6702ef (diff)
downloadVeraCrypt-9d027b02b9723493f66b94bba648e20d48e73b6f.tar.gz
VeraCrypt-9d027b02b9723493f66b94bba648e20d48e73b6f.zip
Static Code Analysis : fix usage of strncpy and sscanf.
Diffstat (limited to 'src')
-rw-r--r--src/Common/Keyfiles.h2
-rw-r--r--src/Format/Tcformat.c2
-rw-r--r--src/Mount/Mount.c12
3 files changed, 8 insertions, 8 deletions
diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h
index 78a8fd53..9ba5b6e8 100644
--- a/src/Common/Keyfiles.h
+++ b/src/Common/Keyfiles.h
@@ -20,7 +20,7 @@ extern "C" {
typedef struct KeyFileStruct
{
- char FileName[MAX_PATH];
+ char FileName[MAX_PATH + 1];
struct KeyFileStruct *Next;
} KeyFile;
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 18dd23ce..0074a169 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -1699,7 +1699,7 @@ static BOOL GetDevicePathForHiddenOS (void)
try
{
- strncpy (szFileName, BootEncObj->GetPartitionForHiddenOS().DevicePath.c_str(), sizeof(szFileName));
+ strncpy (szFileName, BootEncObj->GetPartitionForHiddenOS().DevicePath.c_str(), sizeof(szFileName) - 1);
CreateFullVolumePath (szDiskFile, szFileName, &tmpbDevice);
}
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 3cf9b9a7..bb3a8807 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -783,7 +783,7 @@ BOOL CheckSysEncMountWithoutPBA (const char *devicePath, BOOL quiet)
}
}
else
- strncpy (szDevicePath, devicePath, sizeof (szDevicePath));
+ strncpy (szDevicePath, devicePath, sizeof (szDevicePath) - 1);
char *partionPortion = strrchr (szDevicePath, '\\');
@@ -1866,7 +1866,7 @@ err:
return 0;
}
-static char PasswordDlgVolume[MAX_PATH];
+static char PasswordDlgVolume[MAX_PATH + 1];
static BOOL PasswordDialogDisableMountOptions;
static char *PasswordDialogTitleStringId;
@@ -6700,7 +6700,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
KeyFile *kf;
RelativePath2Absolute (tmpPath);
kf = (KeyFile *) malloc (sizeof (KeyFile));
- strncpy (kf->FileName, tmpPath, sizeof (kf->FileName));
+ strncpy (kf->FileName, tmpPath, sizeof (kf->FileName) - 1);
FirstCmdKeyFile = KeyFileAdd (FirstCmdKeyFile, kf);
}
break;
@@ -7750,7 +7750,7 @@ int RestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
// Open the volume using backup header
while (TRUE)
{
- strncpy (PasswordDlgVolume, lpszVolume, sizeof (PasswordDlgVolume));
+ strncpy (PasswordDlgVolume, lpszVolume, sizeof (PasswordDlgVolume) - 1);
if (!AskVolumePassword (hwndDlg, &VolumePassword, NULL, FALSE))
{
nStatus = ERR_SUCCESS;
@@ -8821,7 +8821,7 @@ void AnalyzeKernelMiniDump (HWND hwndDlg)
}
uint64 bugcheckCode;
- int n = sscanf (output.substr (p + 14, 8).c_str(), "%I64X", &bugcheckCode);
+ int n = sscanf (output.substr (p + 14, 8).c_str(), "%I64uX", &bugcheckCode);
if (n != 1)
{
Error ("ERR_PARAMETER_INCORRECT");
@@ -8831,7 +8831,7 @@ void AnalyzeKernelMiniDump (HWND hwndDlg)
p = output.find ("Arguments ", p);
uint64 bugcheckArgs[4];
- n = sscanf (output.substr (p + 10, (Is64BitOs() ? 17 : 9) * 4).c_str(), "%I64X %I64X %I64X %I64X", &bugcheckArgs[0], &bugcheckArgs[1], &bugcheckArgs[2], &bugcheckArgs[3]);
+ n = sscanf (output.substr (p + 10, (Is64BitOs() ? 17 : 9) * 4).c_str(), "%I64uX %I64uX %I64uX %I64uX", &bugcheckArgs[0], &bugcheckArgs[1], &bugcheckArgs[2], &bugcheckArgs[3]);
if (n != 4)
{
Error ("ERR_PARAMETER_INCORRECT");