Windows: Fix elevated COM format drive validation and device path normalization (#1670)

* Windows: Add input validation whitelists to elevated COM methods

* Windows: Add drive number validation to FormatNtfs and FormatFs COM methods

* Windows: Fix correctness regressions in elevated COM format and device path validation

* Windows: Revert unready COM input validation; keep FormatNtfs/FormatFs return fix
This commit is contained in:
audriusbuika
2026-04-16 04:31:02 +03:00
committed by GitHub
parent 3e9c47d256
commit 4fea6403ce
2 changed files with 5 additions and 1 deletions

View File

@@ -1041,7 +1041,7 @@ namespace VeraCrypt
FileOpen = false;
Elevated = false;
if (path.find(L"\\\\?\\") == 0)
if (path.find(L"\\\\?\\") == 0 || path.find(L"\\\\.\\") == 0)
effectivePath = path;
else
effectivePath = wstring (L"\\\\.\\") + path;

View File

@@ -92,6 +92,8 @@ public:
virtual BOOL STDMETHODCALLTYPE FormatNtfs (int driveNo, int clusterSize)
{
if (driveNo < 0 || driveNo > 25)
return ERROR_INVALID_PARAMETER;
return ::FormatNtfs (driveNo, clusterSize, TRUE);
}
@@ -134,6 +136,8 @@ public:
virtual BOOL STDMETHODCALLTYPE FormatFs (int driveNo, int clusterSize, int fsType)
{
if (driveNo < 0 || driveNo > 25)
return ERROR_INVALID_PARAMETER;
return ::FormatFs (driveNo, clusterSize, fsType, TRUE);
}