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

Linux/MacOSX:check that the requested size of file container is less than available

disk free space. Add a CLI switch to disable this check.
This commit is contained in:
Mounir IDRASSI
2019-10-02 22:28:22 +02:00
parent f16a298d9f
commit 400bb52247
4 changed files with 13 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ namespace VeraCrypt
ArgSize (0), ArgSize (0),
ArgVolumeType (VolumeType::Unknown), ArgVolumeType (VolumeType::Unknown),
ArgTrueCryptMode (false), ArgTrueCryptMode (false),
ArgDisableFileSizeCheck (false),
StartBackgroundTask (false) StartBackgroundTask (false)
{ {
wxCmdLineParser parser; wxCmdLineParser parser;
@@ -96,6 +97,7 @@ namespace VeraCrypt
parser.AddOption (L"", L"volume-type", _("Volume type")); parser.AddOption (L"", L"volume-type", _("Volume type"));
parser.AddParam ( _("Volume path"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddParam ( _("Volume path"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddParam ( _("Mount point"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddParam ( _("Mount point"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch (L"", L"no-size-check", _("Disable check of container size against disk free space."));
wxString str; wxString str;
bool param1IsVolume = false; bool param1IsVolume = false;
@@ -331,6 +333,7 @@ namespace VeraCrypt
ArgForce = parser.Found (L"force"); ArgForce = parser.Found (L"force");
ArgTrueCryptMode = parser.Found (L"truecrypt"); ArgTrueCryptMode = parser.Found (L"truecrypt");
ArgDisableFileSizeCheck = parser.Found (L"no-size-check");
#if !defined(TC_WINDOWS) && !defined(TC_MACOSX) #if !defined(TC_WINDOWS) && !defined(TC_MACOSX)
if (parser.Found (L"fs-options", &str)) if (parser.Found (L"fs-options", &str))

View File

@@ -83,6 +83,7 @@ namespace VeraCrypt
VolumeType::Enum ArgVolumeType; VolumeType::Enum ArgVolumeType;
bool ArgTrueCryptMode; bool ArgTrueCryptMode;
shared_ptr<SecureBuffer> ArgTokenPin; shared_ptr<SecureBuffer> ArgTokenPin;
bool ArgDisableFileSizeCheck;
bool StartBackgroundTask; bool StartBackgroundTask;
UserPreferences Preferences; UserPreferences Preferences;

View File

@@ -21,7 +21,8 @@ namespace VeraCrypt
MaxVolumeSize (0), MaxVolumeSize (0),
MaxVolumeSizeValid (false), MaxVolumeSizeValid (false),
MinVolumeSize (1), MinVolumeSize (1),
SectorSize (sectorSize) SectorSize (sectorSize),
AvailableDiskSpace (0)
{ {
VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1024)); VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1024));
VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (1024 * 1024)); VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (1024 * 1024));
@@ -34,6 +35,10 @@ namespace VeraCrypt
VolumeSizeTextCtrl->Disable(); VolumeSizeTextCtrl->Disable();
VolumeSizeTextCtrl->SetValue (L""); VolumeSizeTextCtrl->SetValue (L"");
} }
else
{
AvailableDiskSpace = (uint64) diskSpace.GetValue ();
}
FreeSpaceStaticText->SetFont (Gui->GetDefaultBoldFont (this)); FreeSpaceStaticText->SetFont (Gui->GetDefaultBoldFont (this));
@@ -97,7 +102,8 @@ namespace VeraCrypt
{ {
try try
{ {
if (GetVolumeSize() >= MinVolumeSize && (!MaxVolumeSizeValid || GetVolumeSize() <= MaxVolumeSize)) uint64 uiVolumeSize = GetVolumeSize();
if (uiVolumeSize >= MinVolumeSize && (!MaxVolumeSizeValid || uiVolumeSize <= MaxVolumeSize) && (CmdLine->ArgDisableFileSizeCheck || !AvailableDiskSpace || uiVolumeSize <= AvailableDiskSpace))
return true; return true;
} }
catch (...) { } catch (...) { }

View File

@@ -49,6 +49,7 @@ namespace VeraCrypt
bool MaxVolumeSizeValid; bool MaxVolumeSizeValid;
uint64 MinVolumeSize; uint64 MinVolumeSize;
uint32 SectorSize; uint32 SectorSize;
uint64 AvailableDiskSpace;
}; };
} }