VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJertzukka <Jertzukka@gmail.com>2024-05-08 20:00:09 +0300
committerGitHub <noreply@github.com>2024-05-08 19:00:09 +0200
commit55c3a8dc58d74bbdd4c39585eff14985838d9896 (patch)
treee2e054689f6341079d5842b9498f9d6e3036371c /src
parente96f3035d9f3fb579de947d57317e596d67468be (diff)
downloadVeraCrypt-55c3a8dc58d74bbdd4c39585eff14985838d9896.tar.gz
VeraCrypt-55c3a8dc58d74bbdd4c39585eff14985838d9896.zip
Fix incorrect max hidden volume size for file containers on CLI (#1338)
Currently the maximum hidden volume size for file containers is limited by available free space on the device the file container resides on, which we do not care about. This commit changes so that only Normal volumes get their `maxVolumeSize` limited by `AvailableDiskSpace`. Also the --size=max parameter is restricted from hidden volume creation as there is no way to determine a good size as we do not mount the outer volume through the CLI process flow to determine available free space on the outer volume.
Diffstat (limited to 'src')
-rw-r--r--src/Main/TextUserInterface.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp
index 0de76c6b..94919296 100644
--- a/src/Main/TextUserInterface.cpp
+++ b/src/Main/TextUserInterface.cpp
@@ -668,7 +668,7 @@ namespace VeraCrypt
{
parentDir = wxT(".");
}
- if (wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace))
+ if (options->Type == VolumeType::Normal && wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace))
{
AvailableDiskSpace = (uint64) diskSpace.GetValue ();
if (maxVolumeSize > AvailableDiskSpace)
@@ -678,10 +678,13 @@ namespace VeraCrypt
if (options->Size == (uint64) (-1))
{
- if (AvailableDiskSpace)
+ if (options->Type == VolumeType::Hidden) {
+ throw_err (_("Please do not use maximum size for hidden volume. As we do not mount the outer volume to determine the available space, it is your responsibility to choose a value so that the hidden volume does not overlap the outer volume."));
+ }
+ else if (AvailableDiskSpace)
{
// caller requesting maximum size
- // we use maxVolumeSize because it is guaranteed to be less of equal to AvailableDiskSpace
+ // we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes
options->Size = maxVolumeSize;
}
else
@@ -702,14 +705,17 @@ namespace VeraCrypt
throw MissingArgument (SRC_POS);
uint64 multiplier = 1024 * 1024;
- wxString sizeStr = AskString (options->Type == VolumeType::Hidden ? _("\nEnter hidden volume size (sizeK/size[M]/sizeG/sizeT/max): ") : _("\nEnter volume size (sizeK/size[M]/sizeG.sizeT/max): "));
+ wxString sizeStr = AskString (options->Type == VolumeType::Hidden ? _("\nEnter hidden volume size (sizeK/size[M]/sizeG/sizeT): ") : _("\nEnter volume size (sizeK/size[M]/sizeG.sizeT/max): "));
if (sizeStr.CmpNoCase(wxT("max")) == 0)
{
multiplier = 1;
- if (AvailableDiskSpace)
+ if (options->Type == VolumeType::Hidden) {
+ throw_err (_("Please do not use maximum size for hidden volume. As we do not mount the outer volume to determine the available space, it is your responsibility to choose a value so that the hidden volume does not overlap the outer volume."));
+ }
+ else if (AvailableDiskSpace)
{
// caller requesting maximum size
- // we use maxVolumeSize because it is guaranteed to be less of equal to AvailableDiskSpace
+ // we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes
options->Size = maxVolumeSize;
}
else