VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkavsrf <kavsrf@gmail.com>2016-08-20 07:35:10 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-09-15 20:35:24 (GMT)
commitb6d7ea98fc46c20b59860edcffac13fee89d69b0 (patch)
treed0a4e2b3145c30db4b0ba9a6a877ee3184a2357a
parent2b284e88262c33a225bda77004a20a23f2214632 (diff)
downloadVeraCrypt-DCS-b6d7ea98fc46c20b59860edcffac13fee89d69b0.zip
VeraCrypt-DCS-b6d7ea98fc46c20b59860edcffac13fee89d69b0.tar.gz
fix double keystrokes
-rw-r--r--Library/CommonLib/EfiConsole.c15
-rw-r--r--Library/PasswordLib/PicturePassword.c11
2 files changed, 20 insertions, 6 deletions
diff --git a/Library/CommonLib/EfiConsole.c b/Library/CommonLib/EfiConsole.c
index 8a87ec8..f03f3f8 100644
--- a/Library/CommonLib/EfiConsole.c
+++ b/Library/CommonLib/EfiConsole.c
@@ -72,7 +72,9 @@ KeyWait(
OUT_PRINT(Prompt, mDelay);
gBS->WaitForEvent(2, InputEvents, &EventIndex);
if (EventIndex == 0) {
- gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
+ if (EFI_ERROR(gST->ConIn->ReadKeyStroke(gST->ConIn, &key))) {
+ continue;
+ }
break;
}
else {
@@ -89,9 +91,12 @@ GetKey(void)
{
EFI_INPUT_KEY key;
UINTN EventIndex;
-
- gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &EventIndex);
- gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
+ EFI_STATUS res1;
+ EFI_STATUS res2;
+ do {
+ res1 = gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &EventIndex);
+ res2 = gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
+ } while (EFI_ERROR(res1) || EFI_ERROR(res2));
return key;
}
@@ -135,6 +140,8 @@ GetLine (
do {
key = GetKey();
+ // Remove dirty chars 0.1s
+ FlushInputDelay(100000);
if ((count >= line_max &&
key.UnicodeChar != CHAR_BACKSPACE) ||
diff --git a/Library/PasswordLib/PicturePassword.c b/Library/PasswordLib/PicturePassword.c
index f917899..67ffcbe 100644
--- a/Library/PasswordLib/PicturePassword.c
+++ b/Library/PasswordLib/PicturePassword.c
@@ -15,6 +15,7 @@ https://opensource.org/licenses/LGPL-3.0
#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/CommonLib.h>
#include <Library/GraphLib.h>
@@ -379,7 +380,14 @@ AskPictPwdInt(
{
curPrevX = curX;
curPrevY = curY;
+ ZeroMem(&key, sizeof(key));
res = gBS->WaitForEvent(eventsCount, InputEvents, &EventIndex);
+ if (EventIndex == 0) {
+ res = gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
+ if (EFI_ERROR(res)) {
+ continue;
+ }
+ }
// OUT_PRINT(L" \r%05d %05d", (UINT32)curX, (UINT32)curY, );
// recharge timeout event and stop beep
if (gBeepControlEnabled && gBeepEnabled && beepOn) {
@@ -406,9 +414,8 @@ AskPictPwdInt(
}
if (EventIndex == 0) {
- gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
+// gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
// OUT_PRINT(L" %04x, %04x\r", key.ScanCode, key.UnicodeChar);
-
// Remove dirty chars 0.1s
FlushInputDelay(100000);
switch (key.ScanCode)