Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
windows:mingw:win64
mingw64-gwenhywfar5
0001-Fix-bug-not-hiding-passwort-in-command-lin...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Fix-bug-not-hiding-passwort-in-command-line.patch of Package mingw64-gwenhywfar5
From 9785a0ae1de4c9b8c0d5a89ab1cb9d6dfff74c48 Mon Sep 17 00:00:00 2001 From: Ralf Habacker <ralf.habacker@freenet.de> Date: Fri, 12 Aug 2022 00:13:51 +0200 Subject: [PATCH] Fix bug not hiding passwort in command line The bug is fixed by adding an initial replacement for the unix variant of GWEN_Gui_CGui__input(), instead of patching the present function, which did not work. Fix #235 --- src/gui/cgui.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/src/gui/cgui.c b/src/gui/cgui.c index 475a9f43..c37bb06e 100644 --- a/src/gui/cgui.c +++ b/src/gui/cgui.c @@ -60,6 +60,9 @@ #ifdef HAVE_ICONV_H # include <iconv.h> #endif +#ifdef OS_WIN32 +#include <windows.h> +#endif #ifndef ICONV_CONST # define ICONV_CONST #endif @@ -162,8 +165,76 @@ char GWEN_Gui_CGui__readCharFromStdin(int waitFor) return chr; } +#ifdef OS_WIN32 +int GWEN_Gui_CGui__input(GWEN_UNUSED GWEN_GUI *gui, + uint32_t flags, + char *buffer, + int minLen, + int maxLen, + uint32_t guiid) +{ + const char ABORT=3; + const char BACKSPACE=8; + const char RETURN=13; + const int show_asterisk=!(flags & GWEN_GUI_INPUT_FLAGS_SHOW); + int rv = 0; + + unsigned char ch=0; + char *p=buffer; + + DWORD con_mode; + DWORD dwRead; + + HANDLE hIn=GetStdHandle(STD_INPUT_HANDLE); + if (hIn == INVALID_HANDLE_VALUE) { + DBG_ERROR(GWEN_LOGDOMAIN, "Cannot get handle to stdin"); + rv=GWEN_ERROR_GENERIC; + return rv; + } + if (!GetConsoleMode(hIn, &con_mode)) { + DBG_ERROR(GWEN_LOGDOMAIN, "Error on getting console mode for stdin: %d", GetLastError()); + rv=GWEN_ERROR_GENERIC; + return rv; + } + if (!SetConsoleMode(hIn, con_mode & ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_OUTPUT))) { + DBG_ERROR(GWEN_LOGDOMAIN, "Error on seting console mode for stdin: %d", GetLastError()); + rv=GWEN_ERROR_GENERIC; + return rv; + } + + while(ReadConsoleA(hIn, &ch, 1, &dwRead, NULL) && ch !=RETURN) { + if (ch==BACKSPACE) { + if (p>buffer) { + if (show_asterisk) { + putchar('\b'); + putchar(' '); + putchar('\b'); + } + *--p='\0'; + } + } else if (ch==ABORT) { + DBG_INFO(GWEN_LOGDOMAIN, "User aborted"); + rv=GWEN_ERROR_USER_ABORTED; + break; + } else if (p-buffer<maxLen) { + *p++=ch; + *p='\0'; + if (show_asterisk) + putchar('*'); + else + putchar(ch); + } + } + putchar('\n'); + if (!SetConsoleMode(hIn, con_mode)) { + DBG_ERROR(GWEN_LOGDOMAIN, "Error on resetting console mode for stdin: %d", GetLastError()); + rv=GWEN_ERROR_GENERIC; + } + return rv; +} +#else int GWEN_Gui_CGui__input(GWEN_UNUSED GWEN_GUI *gui, uint32_t flags, char *buffer, @@ -372,7 +443,7 @@ int GWEN_Gui_CGui__input(GWEN_UNUSED GWEN_GUI *gui, #endif return rv; } - +#endif int GWENHYWFAR_CB GWEN_Gui_CGui_MessageBox(GWEN_GUI *gui, -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor