VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/ExpandVolume
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-10-08 15:56:42 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-10-08 15:56:42 +0200
commit35135cd1fb9765b4c3d6d80f1a3f4b391e145d7c (patch)
tree470efe81998517ed082725d2ec18c163d9a9675f /src/ExpandVolume
parent847abb23f03ca911bd9ed7dbdef97ac2c5469145 (diff)
downloadVeraCrypt-35135cd1fb9765b4c3d6d80f1a3f4b391e145d7c.tar.gz
VeraCrypt-35135cd1fb9765b4c3d6d80f1a3f4b391e145d7c.zip
Windows: Fix expansion of volumes on devices with sector size!=512 (by skl0n6)
Diffstat (limited to 'src/ExpandVolume')
-rw-r--r--src/ExpandVolume/ExpandVolume.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c
index 424948ea..712d23a3 100644
--- a/src/ExpandVolume/ExpandVolume.c
+++ b/src/ExpandVolume/ExpandVolume.c
@@ -508,6 +508,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
PCRYPTO_INFO cryptoInfo = NULL, ci = NULL;
void *dev = INVALID_HANDLE_VALUE;
DWORD dwError;
+ DWORD bytesRead;
BOOL bDevice;
uint64 hostSize=0, newDataAreaSize, currentVolSize;
DWORD HostSectorSize;
@@ -672,8 +673,13 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
}
/* Read in volume header */
- nStatus = _lread ((HFILE) dev, buffer, sizeof (buffer));
- if (nStatus != sizeof (buffer))
+ if (!ReadEffectiveVolumeHeader (bDevice, dev, buffer, &bytesRead))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ if (bytesRead != sizeof (buffer))
{
// Windows may report EOF when reading sectors from the last cluster of a device formatted as NTFS
memset (buffer, 0, sizeof (buffer));