VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Format
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-07-27 17:57:39 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-07-28 17:31:54 +0200
commitc9b5c1073daa9f2ac52ecbb045bd31d4c72c8026 (patch)
treef6e952c2d6b809291e97e6a2427c1da2c803c6f2 /src/Format
parent5649a8b20d38127e70bad94a5f8b9c03263e9dae (diff)
downloadVeraCrypt-c9b5c1073daa9f2ac52ecbb045bd31d4c72c8026.tar.gz
VeraCrypt-c9b5c1073daa9f2ac52ecbb045bd31d4c72c8026.zip
Windows: Don't allow a directory path to be entered for the file container to be created in Format wizard
Diffstat (limited to 'src/Format')
-rw-r--r--src/Format/Tcformat.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 69118669..c9860968 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -5633,8 +5633,24 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (hw == CBN_EDITCHANGE && nCurPageNo == VOLUME_LOCATION_PAGE)
{
+ BOOL bValidEntry = (GetWindowTextLength (GetDlgItem (hCurPage, IDC_COMBO_BOX)) > 0)? TRUE : FALSE;
+
+ if (bValidEntry && !bDevice)
+ {
+ /* check that the entered path is not for an existing directory */
+ WCHAR szEnteredFilePath[TC_MAX_PATH + 1] = {0};
+ GetWindowTextW (GetDlgItem (hCurPage, IDC_COMBO_BOX), szEnteredFilePath, ARRAYSIZE (szEnteredFilePath));
+ RelativePath2Absolute (szEnteredFilePath);
+
+ DWORD dwAttr = GetFileAttributes (szEnteredFilePath);
+ if ((dwAttr != INVALID_FILE_ATTRIBUTES) && (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ /* this is a directory. Consider it as invalid */
+ bValidEntry = FALSE;
+ }
+ }
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT),
- GetWindowTextLength (GetDlgItem (hCurPage, IDC_COMBO_BOX)) > 0);
+ bValidEntry);
bDeviceTransformModeChoiceMade = FALSE;
bInPlaceEncNonSys = FALSE;