From ddeb740426716de91135def46d8408da9d730586 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 16 Jul 2015 10:23:57 -0500 Subject: win32 openssl CLI: preserve original echo state Mirror the patch to ui_openssl.c, also fix the broken conditional that made it not actually turn off echo in the first place. ok guenther@ --- crypto/compat/ui_openssl_win.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crypto') diff --git a/crypto/compat/ui_openssl_win.c b/crypto/compat/ui_openssl_win.c index ecf7376..6597c6a 100644 --- a/crypto/compat/ui_openssl_win.c +++ b/crypto/compat/ui_openssl_win.c @@ -133,6 +133,7 @@ /* Define globals. They are protected by a lock */ static void (*savsig[NX509_SIG])(int ); +DWORD console_mode; static FILE *tty_in, *tty_out; static int is_a_tty; @@ -300,28 +301,27 @@ open_console(UI *ui) tty_in = stdin; tty_out = stderr; - return 1; + HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); + if (handle != INVALID_HANDLE_VALUE) + return GetConsoleMode(handle, &console_mode); + return 0; } static int noecho_console(UI *ui) { - DWORD mode = 0; HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE && handle != handle) { - return GetConsoleMode(handle, &mode) && SetConsoleMode(handle, mode & (~ENABLE_ECHO_INPUT)); - } + if (handle != INVALID_HANDLE_VALUE) + return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT); return 0; } static int echo_console(UI *ui) { - DWORD mode = 0; HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE && handle != handle) { - return GetConsoleMode(handle, &mode) && SetConsoleMode(handle, mode | ENABLE_ECHO_INPUT); - } + if (handle != INVALID_HANDLE_VALUE) + return SetConsoleMode(handle, console_mode); return 0; } -- cgit v1.2.3-55-g6feb