From 27c52464540a2ad8a082fd9835c3394ecabfe4cf Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 29 Oct 2025 11:56:51 +0100 Subject: [PATCH] [utils] fix from-stdin Ignore console tcgetattr/tcsetattr errors. These might not work if data is read from stdin. --- libfreerdp/utils/passphrase.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libfreerdp/utils/passphrase.c b/libfreerdp/utils/passphrase.c index a072f1a39..7c6f8b84f 100644 --- a/libfreerdp/utils/passphrase.c +++ b/libfreerdp/utils/passphrase.c @@ -351,8 +351,8 @@ int freerdp_interruptible_getc(rdpContext* context, FILE* stream) int rc = EOF; const int fd = fileno(stream); - if (!set_termianl_nonblock(fd, TRUE)) - return EOF; + (void)set_termianl_nonblock(fd, TRUE); + do { const int res = wait_for_fd(fd, 10); @@ -374,8 +374,7 @@ int freerdp_interruptible_getc(rdpContext* context, FILE* stream) } } while (!freerdp_shall_disconnect_context(context)); - if (!set_termianl_nonblock(fd, FALSE)) - return EOF; + (void)set_termianl_nonblock(fd, FALSE); return rc; } @@ -416,9 +415,11 @@ SSIZE_T freerdp_interruptible_get_line(rdpContext* context, char** plineptr, siz const int fd = fileno(stream); struct termios termios = { 0 }; - if (tcgetattr(fd, &termios) != 0) - return -1; - echo = (termios.c_lflag & ECHO) != 0; + /* This might fail if /from-stdin is used. */ + if (tcgetattr(fd, &termios) == 0) + echo = (termios.c_lflag & ECHO) != 0; + else + echo = false; } #endif