VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/MainCom.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-02-08 23:46:04 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-02-09 11:01:21 +0100
commitd5f34ad49d345803767d4a1166d764f9f8485541 (patch)
treea101ab51e55dffdbcdef4c15596fd9418df421cd /src/Mount/MainCom.cpp
parent608e86c7bc962f369003d9d05d4402f9da273f0c (diff)
downloadVeraCrypt-d5f34ad49d345803767d4a1166d764f9f8485541.tar.gz
VeraCrypt-d5f34ad49d345803767d4a1166d764f9f8485541.zip
Static Code Analysis: Avoid over-flaw in arithmetic operations by adding more checks. Add extra checks. Solve various issues.
Diffstat (limited to 'src/Mount/MainCom.cpp')
-rw-r--r--src/Mount/MainCom.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/Mount/MainCom.cpp b/src/Mount/MainCom.cpp
index b2dfe89c..5a43d36f 100644
--- a/src/Mount/MainCom.cpp
+++ b/src/Mount/MainCom.cpp
@@ -255,7 +255,17 @@ extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, c
CoInitialize (NULL);
if (ComGetInstance (hwndDlg, &tc))
- r = tc->BackupVolumeHeader ((LONG_PTR) hwndDlg, bRequireConfirmation, CComBSTR (lpszVolume));
+ {
+ CComBSTR volumeBstr;
+ BSTR bstr = A2WBSTR(lpszVolume);
+ if (bstr)
+ {
+ volumeBstr.Attach (bstr);
+ r = tc->BackupVolumeHeader ((LONG_PTR) hwndDlg, bRequireConfirmation, volumeBstr);
+ }
+ else
+ r = ERR_OUTOFMEMORY;
+ }
else
r = -1;
@@ -273,7 +283,17 @@ extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
CoInitialize (NULL);
if (ComGetInstance (hwndDlg, &tc))
- r = tc->RestoreVolumeHeader ((LONG_PTR) hwndDlg, CComBSTR (lpszVolume));
+ {
+ CComBSTR volumeBstr;
+ BSTR bstr = A2WBSTR(lpszVolume);
+ if (bstr)
+ {
+ volumeBstr.Attach (bstr);
+ r = tc->RestoreVolumeHeader ((LONG_PTR) hwndDlg, volumeBstr);
+ }
+ else
+ r = ERR_OUTOFMEMORY;
+ }
else
r = -1;
@@ -291,7 +311,16 @@ extern "C" int UacChangePwd (char *lpszVolume, Password *oldPassword, int old_pk
if (ComGetInstance (hwndDlg, &tc))
{
WaitCursor ();
- r = tc->ChangePasswordEx2 (CComBSTR (lpszVolume), oldPassword, old_pkcs5, truecryptMode, newPassword, pkcs5, wipePassCount, (LONG_PTR) hwndDlg);
+ CComBSTR volumeBstr;
+ BSTR bstr = A2WBSTR(lpszVolume);
+ if (bstr)
+ {
+ volumeBstr.Attach (bstr);
+
+ r = tc->ChangePasswordEx2 (volumeBstr, oldPassword, old_pkcs5, truecryptMode, newPassword, pkcs5, wipePassCount, (LONG_PTR) hwndDlg);
+ }
+ else
+ r = ERR_OUTOFMEMORY;
NormalCursor ();
}
else