Skip to content

Commit

Permalink
Linux/macOS: check if volume doesn't exist before starting the mount …
Browse files Browse the repository at this point in the history
…operation.
  • Loading branch information
idrassi committed Dec 23, 2024
1 parent f05ce4e commit b6e698b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Main/GraphicUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
12 changes: 12 additions & 0 deletions src/Main/TextUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]: "))));
Expand Down

0 comments on commit b6e698b

Please sign in to comment.