VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-07-11 21:21:18 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-07-11 21:21:18 +0200
commit014ed77130f1812d76f8086e5507e11a880799e4 (patch)
treee94f639a4ab1166a37240fe09f2f7de99de68e72 /src
parentb1f578f0efc46381b68cbe3355c5dd13be8c5636 (diff)
downloadVeraCrypt-014ed77130f1812d76f8086e5507e11a880799e4.tar.gz
VeraCrypt-014ed77130f1812d76f8086e5507e11a880799e4.zip
Windows: when overwriting an existing file container, add its current size to the available free space
Diffstat (limited to 'src')
-rw-r--r--src/Format/Tcformat.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index e98a25da..368c7d9e 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -3462,6 +3462,13 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFr
else
{
LARGE_INTEGER lDiskFree;
+ // if the file pointed by szFileName already exists, we must add its size to the free space since it will be overwritten durig the volume creation
+ __int64 lFileSize = GetFileSize64(szFileName);
+ if (lFileSize != -1)
+ {
+ free.QuadPart += lFileSize;
+ }
+
lDiskFree.QuadPart = free.QuadPart;
if (pFreeSpaceValue)