From 6bb1f24ed571bccd4d1d247dafdc1dda6eaa3d8d Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 4 Feb 2019 11:37:37 +0100 Subject: Automatically truncate passwords for TrueCrypt volumes and System Encryption to the first 64 characters. This fix issues encountered by users of TrueCrypt volumes who were using passwords longer than 64 characters that were truncated in previous version. --- src/Common/Dlgcode.c | 4 +++- src/Common/Dlgcode.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Common') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 44cf623b..c8efe2a7 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -13047,13 +13047,15 @@ void SetPim (HWND hwndDlg, UINT ctrlId, int pim) SetDlgItemText (hwndDlg, ctrlId, L""); } -BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError) +BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bLegacyPassword, BOOL bShowError) { wchar_t tmp [MAX_PASSWORD + 1]; int utf8Len; BOOL bRet = FALSE; GetWindowText (GetDlgItem (hwndDlg, ctrlID), tmp, ARRAYSIZE (tmp)); + if (bLegacyPassword && (lstrlen (tmp) > MAX_LEGACY_PASSWORD)) + wmemset (&tmp[MAX_LEGACY_PASSWORD], 0, MAX_PASSWORD + 1 - MAX_LEGACY_PASSWORD); utf8Len = WideCharToMultiByte (CP_UTF8, 0, tmp, -1, passValue, bufSize, NULL, NULL); burn (tmp, sizeof (tmp)); if (utf8Len > 0) diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index 00a49239..e97e50cf 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -515,7 +515,7 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath); BOOL IsApplicationInstalled (const wchar_t *appName); int GetPim (HWND hwndDlg, UINT ctrlId, int defaultPim); void SetPim (HWND hwndDlg, UINT ctrlId, int pim); -BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError); +BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bLegacyPassword, BOOL bShowError); void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue); void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id); HKEY OpenDeviceClassRegKey (const GUID *deviceClassGuid); -- cgit v1.2.3