VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-12-23 23:10:37 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-12-23 23:10:37 +0100
commitb6e698b376dd5754f7855fb8666644dd2b7b5739 (patch)
treee05bb33e40c87b68f7435a0dcb88ef20cb02e3ec /src/Main
parentf05ce4eaf32da72e85eac86f21c4009279906d37 (diff)
downloadVeraCrypt-b6e698b376dd5754f7855fb8666644dd2b7b5739.tar.gz
VeraCrypt-b6e698b376dd5754f7855fb8666644dd2b7b5739.zip
Linux/macOS: check if volume doesn't exist before starting the mount operation.
Diffstat (limited to 'src/Main')
-rw-r--r--src/Main/GraphicUserInterface.cpp13
-rw-r--r--src/Main/TextUserInterface.cpp12
2 files changed, 25 insertions, 0 deletions
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp
index 1cb62671..b8098e95 100644
--- a/src/Main/GraphicUserInterface.cpp
+++ b/src/Main/GraphicUserInterface.cpp
@@ -825,8 +825,21 @@ namespace VeraCrypt
ShowInfo (StringFormatter (LangString["VOLUME_ALREADY_MOUNTED"], wstring (*options.Path)));
return volume;
}
+
+ // check if the volume path exists using stat function. Only ENOENT error is handled to exclude permission denied error
+ struct stat statBuf;
+ if (stat (string (*options.Path).c_str(), &statBuf) != 0)
+ {
+ if (errno == ENOENT)
+ {
+ SystemException ex (SRC_POS);
+ ShowError (ex);
+ return volume;
+ }
+ }
+
try
{
if ((!options.Password || options.Password->IsEmpty())
&& (!options.Keyfiles || options.Keyfiles->empty())
diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp
index bc3f6f5a..5dd778a0 100644
--- a/src/Main/TextUserInterface.cpp
+++ b/src/Main/TextUserInterface.cpp
@@ -1334,8 +1334,20 @@ namespace VeraCrypt
ShowInfo (StringFormatter (LangString["VOLUME_ALREADY_MOUNTED"], wstring (*options.Path)));
return volume;
}
+ // check if the volume path exists using stat function. Only ENOENT error is handled to exclude permission denied error
+ struct stat statBuf;
+ if (stat (string (*options.Path).c_str(), &statBuf) != 0)
+ {
+ if (errno == ENOENT)
+ {
+ SystemException ex (SRC_POS);
+ ShowError (ex);
+ return volume;
+ }
+ }
+
// Mount point
if (!options.MountPoint && !options.NoFilesystem)
options.MountPoint.reset (new DirectoryPath (AskString (_("Enter mount directory [default]: "))));