VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-08-05 18:18:31 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-08-06 00:36:37 +0200
commit709964e156f52a28416f2c7350dacbbe665af9c9 (patch)
treefbd9acc78e7773baf4bfe26c45490ec9d7c96c36 /src/Common
parent388e44c8095c04eac53ca6500363ebfb0d8f14bb (diff)
downloadVeraCrypt-709964e156f52a28416f2c7350dacbbe665af9c9.tar.gz
VeraCrypt-709964e156f52a28416f2c7350dacbbe665af9c9.zip
Windows: Display warning message with correct maximum length value when password is truncated
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Dlgcode.c44
-rw-r--r--src/Common/Language.xml6
2 files changed, 42 insertions, 8 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 6fcd16c3..04f35044 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -1288,9 +1288,13 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar
if (curLen == dwMaxPassLen)
{
EDITBALLOONTIP ebt;
+ DWORD dwTextSize = (DWORD) wcslen (GetString ("PASSWORD_MAXLENGTH_REACHED")) + 16;
+ WCHAR* szErrorText = (WCHAR*) malloc (dwTextSize * sizeof (WCHAR));
+
+ StringCchPrintf (szErrorText, dwTextSize, GetString ("PASSWORD_MAXLENGTH_REACHED"), dwMaxPassLen);
ebt.cbStruct = sizeof( EDITBALLOONTIP );
- ebt.pszText = GetString ("PASSWORD_MAXLENGTH_REACHED");
+ ebt.pszText = szErrorText;
ebt.pszTitle = lpszTitle;
ebt.ttiIcon = TTI_ERROR_LARGE; // tooltip warning icon
@@ -1298,20 +1302,28 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar
MessageBeep (0xFFFFFFFF);
+ free (szErrorText);
+
bBlock = true;
}
else if ((txtlen + curLen) > dwMaxPassLen)
{
EDITBALLOONTIP ebt;
+ DWORD dwTextSize = (DWORD) wcslen (GetString ("PASSWORD_PASTED_TRUNCATED")) + 16;
+ WCHAR* szErrorText = (WCHAR*) malloc (dwTextSize * sizeof (WCHAR));
+
+ StringCchPrintf (szErrorText, dwTextSize, GetString ("PASSWORD_PASTED_TRUNCATED"), dwMaxPassLen);
ebt.cbStruct = sizeof( EDITBALLOONTIP );
- ebt.pszText = GetString ("PASSWORD_PASTED_TRUNCATED");
+ ebt.pszText = szErrorText;
ebt.pszTitle = lpszTitle;
ebt.ttiIcon = TTI_WARNING_LARGE; // tooltip warning icon
SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt);
MessageBeep (0xFFFFFFFF);
+
+ free (szErrorText);
}
else
SendMessage(hwnd, EM_HIDEBALLOONTIP, 0, 0);
@@ -1343,15 +1355,21 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar
&& (GetWindowTextLength (hwnd) == dwMaxPassLen))
{
EDITBALLOONTIP ebt;
+ DWORD dwTextSize = (DWORD) wcslen (GetString ("PASSWORD_MAXLENGTH_REACHED")) + 16;
+ WCHAR* szErrorText = (WCHAR*) malloc (dwTextSize * sizeof (WCHAR));
+
+ StringCchPrintf (szErrorText, dwTextSize, GetString ("PASSWORD_MAXLENGTH_REACHED"), dwMaxPassLen);
ebt.cbStruct = sizeof( EDITBALLOONTIP );
- ebt.pszText = GetString ("PASSWORD_MAXLENGTH_REACHED");
+ ebt.pszText = szErrorText;
ebt.pszTitle = lpszTitle;
ebt.ttiIcon = TTI_ERROR_LARGE; // tooltip warning icon
SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt);
MessageBeep (0xFFFFFFFF);
+
+ free (szErrorText);
}
else
SendMessage(hwnd, EM_HIDEBALLOONTIP, 0, 0);
@@ -13229,7 +13247,17 @@ BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL
{
SetFocus (GetDlgItem(hwndDlg, ctrlID));
if (GetLastError () == ERROR_INSUFFICIENT_BUFFER)
- Error ((bufSize == (MAX_LEGACY_PASSWORD + 1))? "LEGACY_PASSWORD_UTF8_TOO_LONG": "PASSWORD_UTF8_TOO_LONG", hwndDlg);
+ {
+ DWORD dwTextSize = (DWORD) wcslen (GetString ("PASSWORD_UTF8_TOO_LONG")) + 16;
+ WCHAR* szErrorText = (WCHAR*) malloc (dwTextSize * sizeof (WCHAR));
+
+ // bufSize is equal to maximum password length plus one
+ StringCchPrintf (szErrorText, dwTextSize, GetString ("PASSWORD_UTF8_TOO_LONG"), (bufSize - 1));
+
+ ErrorDirect (szErrorText, hwndDlg);
+
+ free (szErrorText);
+ }
else
Error ("PASSWORD_UTF8_INVALID", hwndDlg);
}
@@ -14899,15 +14927,21 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format)
if (bTruncated)
{
EDITBALLOONTIP ebt;
+ DWORD dwTextSize = (DWORD) wcslen (GetString ("PASSWORD_PASTED_TRUNCATED")) + 16;
+ WCHAR* szErrorText = (WCHAR*) malloc (dwTextSize * sizeof (WCHAR));
+
+ StringCchPrintf (szErrorText, dwTextSize, GetString ("PASSWORD_PASTED_TRUNCATED"), maxLen);
ebt.cbStruct = sizeof( EDITBALLOONTIP );
- ebt.pszText = GetString ("PASSWORD_PASTED_TRUNCATED");
+ ebt.pszText = szErrorText;
ebt.pszTitle = lpszTitle;
ebt.ttiIcon = TTI_WARNING_LARGE; // tooltip warning icon
SendMessage(hChild, EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt);
MessageBeep (0xFFFFFFFF);
+
+ free (szErrorText);
}
}
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index e0e657c9..3144c3a6 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -1378,7 +1378,7 @@
<entry lang="en" key="IDC_BOOT_LOADER_CACHE_PIM">Include &amp;PIM when caching pre-boot authentication password</entry>
<entry lang="en" key="IDC_PREF_CACHE_PIM">Include PIM when caching a password</entry>
<entry lang="en" key="IDC_SHOW_DISCONNECTED_NETWORK_DRIVES">Make disconnected network drives available for mounting</entry>
- <entry lang="en" key="PASSWORD_UTF8_TOO_LONG">The entered password is too long: its UTF-8 representation exceeds 128 bytes.</entry>
+ <entry lang="en" key="PASSWORD_UTF8_TOO_LONG">The entered password is too long: its UTF-8 representation exceeds %d bytes.</entry>
<entry lang="en" key="PASSWORD_UTF8_INVALID">The entered password contains Unicode characters that couldn't be converted to UTF-8 representation.</entry>
<entry lang="en" key="INIT_DLL">Error: Failed to load a system library.</entry>
<entry lang="en" key="ERR_EXFAT_INVALID_VOLUME_SIZE">The volume file size specified in the command line is incompatible with selected exFAT filesystem.</entry>
@@ -1421,8 +1421,8 @@
<entry lang="en" key="IDC_BLOCK_SYSENC_TRIM">Block TRIM command on system partition/drive</entry>
<entry lang="en" key="WINDOWS_EFI_BOOT_LOADER_MISSING">ERROR: Windows EFI system loader could not be located on the disk. Operation will be aborted.</entry>
<entry lang="en" key="SYSENC_EFI_UNSUPPORTED_SECUREBOOT">It is currently not possible to encrypt a system if SecureBoot is enabled and if VeraCrypt custom keys are not loaded into the machine firmware. SecureBoot needs to be disabled in the BIOS configuration in order to allow system encryption to proceed.</entry>
- <entry lang="en" key="PASSWORD_PASTED_TRUNCATED">Pasted text truncated because the password maximum length is 128 characters</entry>
- <entry lang="en" key="PASSWORD_MAXLENGTH_REACHED">Password already reached its maximum length of 128 characters.\nNo additional character is allowed.</entry>
+ <entry lang="en" key="PASSWORD_PASTED_TRUNCATED">Pasted text truncated because the password maximum length is %d characters</entry>
+ <entry lang="en" key="PASSWORD_MAXLENGTH_REACHED">Password already reached its maximum length of %d characters.\nNo additional character is allowed.</entry>
<entry lang="en" key="IDC_SELECT_LANGUAGE_LABEL">Select the language to use during the installation:</entry>
<entry lang="en" key="VOLUME_TOO_LARGE_FOR_HOST">ERROR: The size of the file container is larger than the available free space on disk.</entry>
<entry lang="en" key="IDC_ALLOW_WINDOWS_DEFRAG">Allow Windows Disk Defragmenter to defragment non-system partition/drive</entry>