Compare commits

...
Author SHA1 Message Date
Mounir IDRASSI 177ec1fce1 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.
2026-06-14 23:18:10 +09:00
Damian RickardandClaude Fable 5 2dbc718225 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.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:37:32 -04:00
+8 -5
View File
@@ -766,7 +766,10 @@ namespace VeraCrypt
if (options->Type == VolumeType::Normal && wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace)) if (options->Type == VolumeType::Normal && wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace))
{ {
AvailableDiskSpace = (uint64) diskSpace.GetValue (); 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; maxVolumeSize = AvailableDiskSpace;
} }
} }
@@ -779,8 +782,8 @@ namespace VeraCrypt
else if (AvailableDiskSpace) else if (AvailableDiskSpace)
{ {
// caller requesting maximum size // caller requesting maximum size
// we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes // Limit "max" to available disk space even when --no-size-check allows explicit sparse sizes beyond it.
options->Size = maxVolumeSize; options->Size = VC_MIN (maxVolumeSize, AvailableDiskSpace);
} }
else else
{ {
@@ -808,8 +811,8 @@ namespace VeraCrypt
else if (AvailableDiskSpace) else if (AvailableDiskSpace)
{ {
// caller requesting maximum size // caller requesting maximum size
// we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes // Limit "max" to available disk space even when --no-size-check allows explicit sparse sizes beyond it.
options->Size = maxVolumeSize; options->Size = VC_MIN (maxVolumeSize, AvailableDiskSpace);
} }
else else
{ {