diff --git a/contrib/valgrind.supp b/contrib/valgrind.supp index ef53f380081..c7a890aa5a4 100644 --- a/contrib/valgrind.supp +++ b/contrib/valgrind.supp @@ -14,12 +14,6 @@ # Note that suppressions may depend on OS and/or library versions. # Tested on aarch64 and x86_64 with Ubuntu Noble system libs, using clang-16 # and GCC, without gui. -{ - Suppress uninitialized bytes warning in compat code - Memcheck:Param - ioctl(TCSET{S,SW,SF}) - fun:tcsetattr -} { Suppress leaks on shutdown Memcheck:Leak diff --git a/src/compat/stdin.cpp b/src/compat/stdin.cpp index 20540f2ad61..10c811ad380 100644 --- a/src/compat/stdin.cpp +++ b/src/compat/stdin.cpp @@ -18,25 +18,38 @@ // https://stackoverflow.com/questions/1413445/reading-a-password-from-stdcin void SetStdinEcho(bool enable) { + if (!StdinTerminal()) { + return; + } #ifdef WIN32 HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); DWORD mode; - GetConsoleMode(hStdin, &mode); + if (!GetConsoleMode(hStdin, &mode)) { + fputs("GetConsoleMode failed\n", stderr); + return; + } if (!enable) { mode &= ~ENABLE_ECHO_INPUT; } else { mode |= ENABLE_ECHO_INPUT; } - SetConsoleMode(hStdin, mode); + if (!SetConsoleMode(hStdin, mode)) { + fputs("SetConsoleMode failed\n", stderr); + } #else struct termios tty; - tcgetattr(STDIN_FILENO, &tty); + if (tcgetattr(STDIN_FILENO, &tty) != 0) { + fputs("tcgetattr failed\n", stderr); + return; + } if (!enable) { - tty.c_lflag &= ~ECHO; + tty.c_lflag &= static_cast(~ECHO); } else { tty.c_lflag |= ECHO; } - (void)tcsetattr(STDIN_FILENO, TCSANOW, &tty); + if (tcsetattr(STDIN_FILENO, TCSANOW, &tty) != 0) { + fputs("tcsetattr failed\n", stderr); + } #endif } diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index 0151f9d0253..ad604e6357b 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -55,7 +55,6 @@ unsigned-integer-overflow:TxConfirmStats::EstimateMedianVal unsigned-integer-overflow:InsecureRandomContext::rand64 unsigned-integer-overflow:InsecureRandomContext::SplitMix64 unsigned-integer-overflow:bitset_detail::PopCount -implicit-integer-sign-change:SetStdinEcho implicit-integer-sign-change:compressor.h implicit-integer-sign-change:crypto/ implicit-integer-sign-change:TxConfirmStats::removeTx