mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-06-17 01:56:10 -05:00
Honor --no-size-check in CLI volume creation (#1756)
* Honor --no-size-check when creating file containers via the CLI The text-mode volume creation path clamps the maximum allowed volume size to the available free disk space and never consults ArgDisableFileSizeCheck, so the documented --no-size-check switch has no effect when creating a file-hosted container with `--text --create`. The flag is honored by the GUI wizard (Forms/VolumeSizeWizardPage.cpp) but was missing from the text UI, making it impossible to create a (sparse) container larger than the current free space from the command line -- even though such a container is perfectly valid on filesystems with sparse-file support (e.g. APFS, ext4, NTFS) and is exactly what the flag exists to allow. Skip the free-space clamp when --no-size-check is set, mirroring the GUI behavior. * Fix max volume size handling with no-size-check Keep the max size sentinel and interactive max choice bounded by available disk space even when --no-size-check allows explicit sparse container sizes beyond the current free space. --------- Co-authored-by: Damian Rickard <damian@rickard.us> Co-authored-by: Mounir IDRASSI <mounir.idrassi@amcrypto.jp>
This commit is contained in:
@@ -766,7 +766,10 @@ namespace VeraCrypt
|
||||
if (options->Type == VolumeType::Normal && wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace))
|
||||
{
|
||||
AvailableDiskSpace = (uint64) diskSpace.GetValue ();
|
||||
if (maxVolumeSize > AvailableDiskSpace)
|
||||
// Honor --no-size-check so a (sparse) file container larger than the
|
||||
// current free space can be created from the command line, mirroring
|
||||
// the GUI wizard behavior (see VolumeSizeWizardPage.cpp).
|
||||
if (maxVolumeSize > AvailableDiskSpace && !CmdLine->ArgDisableFileSizeCheck)
|
||||
maxVolumeSize = AvailableDiskSpace;
|
||||
}
|
||||
}
|
||||
@@ -779,8 +782,8 @@ namespace VeraCrypt
|
||||
else if (AvailableDiskSpace)
|
||||
{
|
||||
// caller requesting maximum size
|
||||
// we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes
|
||||
options->Size = maxVolumeSize;
|
||||
// Limit "max" to available disk space even when --no-size-check allows explicit sparse sizes beyond it.
|
||||
options->Size = VC_MIN (maxVolumeSize, AvailableDiskSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -808,8 +811,8 @@ namespace VeraCrypt
|
||||
else if (AvailableDiskSpace)
|
||||
{
|
||||
// caller requesting maximum size
|
||||
// we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes
|
||||
options->Size = maxVolumeSize;
|
||||
// Limit "max" to available disk space even when --no-size-check allows explicit sparse sizes beyond it.
|
||||
options->Size = VC_MIN (maxVolumeSize, AvailableDiskSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user