From 3af1387b189074ef82410627f51b84277aa24aa2 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 11 Dec 2015 09:22:12 -0600 Subject: Revert back to GetStdHandle, since it works fine with pipes. Also include the formerly-missing NULL check, since this can fail in two ways. --- crypto/compat/ui_openssl_win.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crypto') diff --git a/crypto/compat/ui_openssl_win.c b/crypto/compat/ui_openssl_win.c index 959352b..ad9e915 100644 --- a/crypto/compat/ui_openssl_win.c +++ b/crypto/compat/ui_openssl_win.c @@ -301,8 +301,8 @@ open_console(UI *ui) tty_in = stdin; tty_out = stderr; - HANDLE handle = (HANDLE)_get_osfhandle(_fileno(stdin)); - if (handle != INVALID_HANDLE_VALUE) { + HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); + if (handle != NULL && handle != INVALID_HANDLE_VALUE) { if (GetFileType(handle) == FILE_TYPE_CHAR) return GetConsoleMode(handle, &console_mode); else @@ -314,8 +314,8 @@ open_console(UI *ui) static int noecho_console(UI *ui) { - HANDLE handle = (HANDLE)_get_osfhandle(_fileno(stdin)); - if (handle != INVALID_HANDLE_VALUE) { + HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); + if (handle != NULL && handle != INVALID_HANDLE_VALUE) { if (GetFileType(handle) == FILE_TYPE_CHAR) return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT); else @@ -327,8 +327,8 @@ noecho_console(UI *ui) static int echo_console(UI *ui) { - HANDLE handle = (HANDLE)_get_osfhandle(_fileno(stdin)); - if (handle != INVALID_HANDLE_VALUE) { + HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); + if (handle != NULL && handle != INVALID_HANDLE_VALUE) { if (GetFileType(handle) == FILE_TYPE_CHAR) return SetConsoleMode(handle, console_mode); else -- cgit v1.2.3-55-g6feb