1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Linux/macOS: check if volume doesn't exist before starting the mount operation.

This commit is contained in:
Mounir IDRASSI
2024-12-23 23:10:37 +01:00
parent f05ce4eaf3
commit b6e698b376
2 changed files with 25 additions and 0 deletions

View File

@@ -826,6 +826,19 @@ namespace VeraCrypt
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())

View File

@@ -1335,6 +1335,18 @@ namespace VeraCrypt
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]: "))));