From d26eef9252677bfe06ed76eedc11db3001283814 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 26 Feb 2019 12:43:07 +0100 Subject: [PATCH] shared/ask-password-api: when echoing multi-byte characters, print the whole sequence This is untested, but I don't see how the previous code could have worked for multibyte characters (with echo on). --- src/shared/ask-password-api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index bc5e1cf6692..a3d61d5b9ab 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -442,8 +442,11 @@ int ask_password_tty( /* Check if we got a complete UTF-8 character now. If so, let's output one '*'. */ n = utf8_encoded_valid_unichar(passphrase + codepoint, (size_t) -1); if (n >= 0) { + if (flags & ASK_PASSWORD_ECHO) + (void) loop_write(ttyfd, passphrase + codepoint, n, false); + else + (void) loop_write(ttyfd, "*", 1, false); codepoint = p; - (void) loop_write(ttyfd, (flags & ASK_PASSWORD_ECHO) ? &c : "*", 1, false); } } -- 2.47.3