mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-23 19:43:27 +01:00
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.
This commit is contained in:
parent
e96f3035d9
commit
55c3a8dc58
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user