From 36a11ef8d5a07b06c8702bf625531bac8e33aa7c Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 5 Mar 2019 21:05:35 +0000 Subject: [PATCH] Use the new StripCtrlChars for terminal-based auth prompts. SSH authentication prompts (passwords, passphrases and keyboard- interactive) were previously sanitised to remove escape sequences by the simplistic sanitise_term_data() in utils.c. Now they're fed through the new mode of StripCtrlChars instead, which means they should permit printable Unicode (if the terminal is in UTF-8 mode) while still disallowing escape sequences. Hopefully this will be a usability improvement to everyone whose login prompts are in a language not representable in plain ASCII. --- terminal.c | 6 +++++- terminal.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index 794ffa82..6f921c2e 100644 --- a/terminal.c +++ b/terminal.c @@ -1644,6 +1644,9 @@ Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata, TermWin *win) term->paste_buffer = NULL; term->paste_len = 0; bufchain_init(&term->inbuf); + bufchain_sink_init(&term->inbuf_bs, &term->inbuf); + term->inbuf_scc = stripctrl_new_term( + BinarySink_UPCAST(&term->inbuf_bs), false, 0, term); bufchain_init(&term->printer_buf); term->printing = term->only_printing = false; term->print_job = NULL; @@ -1736,6 +1739,7 @@ void term_free(Terminal *term) term->beephead = beep->next; sfree(beep); } + stripctrl_free(term->inbuf_scc); bufchain_clear(&term->inbuf); if(term->print_job) printer_finish_job(term->print_job); @@ -6775,7 +6779,7 @@ size_t term_data(Terminal *term, bool is_stderr, const void *data, size_t len) static void term_data_untrusted(Terminal *term, const void *data, size_t len) { - sanitise_term_data(&term->inbuf, data, len); + put_data(term->inbuf_scc, data, len); term_added_data(term); } diff --git a/terminal.h b/terminal.h index eae4c7fa..6f86c928 100644 --- a/terminal.h +++ b/terminal.h @@ -100,6 +100,9 @@ struct terminal_tag { termchar basic_erase_char, erase_char; bufchain inbuf; /* terminal input buffer */ + bufchain_sink inbuf_bs; + StripCtrlChars *inbuf_scc; + pos curs; /* cursor */ pos savecurs; /* saved cursor position */ int marg_t, marg_b; /* scroll margins */