VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2022-03-26 20:01:05 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2022-03-26 21:15:04 +0100
commita0809fe85c2f1bf130c26ff77aea7dac19b6c05f (patch)
treea53e613f14530310543c578ed171ae3abb667408 /src
parent05fd14006d0ee5991f207d2f98a1a9ab0b4060fb (diff)
downloadVeraCrypt-a0809fe85c2f1bf130c26ff77aea7dac19b6c05f.tar.gz
VeraCrypt-a0809fe85c2f1bf130c26ff77aea7dac19b6c05f.zip
Windows: check result of WriteFile and don't block if it is failing (Coverity)
Diffstat (limited to 'src')
-rw-r--r--src/Common/Format.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Common/Format.c b/src/Common/Format.c
index f691c78d..4363f474 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -1216,10 +1216,16 @@ BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType)
DWORD dwExitCode, dwWritten;
LPCSTR newLine = "\n";
- WriteFile(hChildStd_IN_Wr, (LPCVOID) newLine, 1, &dwWritten, NULL);
-
- /* wait for the format process to finish */
- WaitForSingleObject (piProcInfo.hProcess, INFINITE);
+ if (WriteFile(hChildStd_IN_Wr, (LPCVOID) newLine, 1, &dwWritten, NULL))
+ {
+ /* wait for the format process to finish */
+ WaitForSingleObject (piProcInfo.hProcess, INFINITE);
+ }
+ else
+ {
+ /* we failed to write "\n". Maybe process exited too quickly. We wait 1 second */
+ WaitForSingleObject (piProcInfo.hProcess, 1000);
+ }
/* check if it was successfull */
if (GetExitCodeProcess (piProcInfo.hProcess, &dwExitCode))