From 380ca35c6d34437380de252058bb68817c925810 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 24 Aug 2024 18:02:16 +0200 Subject: [PATCH] Windows: Fix regression causing crash when a wrong password is used when changing password of volumes --- src/Common/BootEncryption.cpp | 2 +- src/Common/Password.c | 2 +- src/ExpandVolume/ExpandVolume.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 9fdcea29ed..fe0cdb098d 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -5443,7 +5443,7 @@ namespace VeraCrypt finally_do_arg (PCRYPTO_INFO, cryptoInfo, { if (finally_arg) crypto_close (finally_arg); }); // if the XTS master key is vulnerable, return error and do not allow the user to change the password since the master key will not be changed - if (cryptoInfo->bVulnerableMasterKey) + if ((status == 0) && cryptoInfo->bVulnerableMasterKey) status = ERR_SYSENC_XTS_MASTERKEY_VULNERABLE; if (status != 0) diff --git a/src/Common/Password.c b/src/Common/Password.c index f20dd25705..c0247207da 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -372,7 +372,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, nStatus = 0; // We can ignore this error here // if the XTS master key is vulnerable, return error and do not allow the user to change the password since the master key will not be changed - if (cryptoInfo->bVulnerableMasterKey) + if ((nStatus == 0) && cryptoInfo->bVulnerableMasterKey) nStatus = ERR_XTS_MASTERKEY_VULNERABLE; if (nStatus == ERR_PASSWORD_WRONG) diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c index f79fd5b769..34184ddaf3 100644 --- a/src/ExpandVolume/ExpandVolume.c +++ b/src/ExpandVolume/ExpandVolume.c @@ -692,7 +692,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas nStatus = 0; // We can ignore this error here // if the volume master key is vulnerable, print a warning to inform the user - if (cryptoInfo->bVulnerableMasterKey) + if ((nStatus == 0) && cryptoInfo->bVulnerableMasterKey) { DebugAddProgressDlgStatus(hwndDlg, GetString ("ERR_XTS_MASTERKEY_VULNERABLE_SHORT")); }