From 400bb5224700e7dcaa2eb3572a3ba2a3fbdf02e1 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 2 Oct 2019 22:28:22 +0200 Subject: 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. --- src/Main/CommandLineInterface.cpp | 3 +++ src/Main/CommandLineInterface.h | 1 + src/Main/Forms/VolumeSizeWizardPage.cpp | 10 ++++++++-- src/Main/Forms/VolumeSizeWizardPage.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Main') diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index 68d308fa..a0924de4 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -30,6 +30,7 @@ namespace VeraCrypt ArgSize (0), ArgVolumeType (VolumeType::Unknown), ArgTrueCryptMode (false), + ArgDisableFileSizeCheck (false), StartBackgroundTask (false) { wxCmdLineParser parser; @@ -96,6 +97,7 @@ namespace VeraCrypt parser.AddOption (L"", L"volume-type", _("Volume type")); 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.AddSwitch (L"", L"no-size-check", _("Disable check of container size against disk free space.")); wxString str; bool param1IsVolume = false; @@ -331,6 +333,7 @@ namespace VeraCrypt ArgForce = parser.Found (L"force"); ArgTrueCryptMode = parser.Found (L"truecrypt"); + ArgDisableFileSizeCheck = parser.Found (L"no-size-check"); #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) if (parser.Found (L"fs-options", &str)) diff --git a/src/Main/CommandLineInterface.h b/src/Main/CommandLineInterface.h index cc4c317e..9fd67a27 100644 --- a/src/Main/CommandLineInterface.h +++ b/src/Main/CommandLineInterface.h @@ -83,6 +83,7 @@ namespace VeraCrypt VolumeType::Enum ArgVolumeType; bool ArgTrueCryptMode; shared_ptr ArgTokenPin; + bool ArgDisableFileSizeCheck; bool StartBackgroundTask; UserPreferences Preferences; diff --git a/src/Main/Forms/VolumeSizeWizardPage.cpp b/src/Main/Forms/VolumeSizeWizardPage.cpp index f4044418..3781b05d 100644 --- a/src/Main/Forms/VolumeSizeWizardPage.cpp +++ b/src/Main/Forms/VolumeSizeWizardPage.cpp @@ -21,7 +21,8 @@ namespace VeraCrypt MaxVolumeSize (0), MaxVolumeSizeValid (false), MinVolumeSize (1), - SectorSize (sectorSize) + SectorSize (sectorSize), + AvailableDiskSpace (0) { VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast (1024)); VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast (1024 * 1024)); @@ -34,6 +35,10 @@ namespace VeraCrypt VolumeSizeTextCtrl->Disable(); VolumeSizeTextCtrl->SetValue (L""); } + else + { + AvailableDiskSpace = (uint64) diskSpace.GetValue (); + } FreeSpaceStaticText->SetFont (Gui->GetDefaultBoldFont (this)); @@ -97,7 +102,8 @@ namespace VeraCrypt { try { - if (GetVolumeSize() >= MinVolumeSize && (!MaxVolumeSizeValid || GetVolumeSize() <= MaxVolumeSize)) + uint64 uiVolumeSize = GetVolumeSize(); + if (uiVolumeSize >= MinVolumeSize && (!MaxVolumeSizeValid || uiVolumeSize <= MaxVolumeSize) && (CmdLine->ArgDisableFileSizeCheck || !AvailableDiskSpace || uiVolumeSize <= AvailableDiskSpace)) return true; } catch (...) { } diff --git a/src/Main/Forms/VolumeSizeWizardPage.h b/src/Main/Forms/VolumeSizeWizardPage.h index e12a5a79..aac41f99 100644 --- a/src/Main/Forms/VolumeSizeWizardPage.h +++ b/src/Main/Forms/VolumeSizeWizardPage.h @@ -49,6 +49,7 @@ namespace VeraCrypt bool MaxVolumeSizeValid; uint64 MinVolumeSize; uint32 SectorSize; + uint64 AvailableDiskSpace; }; } -- cgit v1.2.3