From edd5e13ffc976025443e0b9d75888249aa3325a9 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 14 Dec 2024 11:44:28 +0000 Subject: [PATCH] Fix assertion failure on Restart Session. This occurred if the SSH server closed the connection for any reason (in practice usually a timeout, but reproducible more easily by manually killing a test server process) while the user was in the middle of any kind of interactive prompt-based login in the GUI PuTTY terminal (be it simple password, k-i, private key passphrase, whatever). The problem was that term->userpass_state wasn't cleaned up when the connection died, and then if you started a fresh SSH session in the same terminal, the attempt to create a new term->userpass_state would find there was one already there. The simplest place to insert the missing cleanup is the call to term_provide_backend(), because that's a terminal API function which is already called to notify the terminal that one backend has gone away and the next one has turned up. (In fact, it's called twice, once to set term->backend to NULL when the first session closes, and again when the session is restarted. I see no harm in making the cleanup unconditional, not bothering to tell the difference between the two cases.) --- terminal/terminal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terminal/terminal.c b/terminal/terminal.c index e127ff6e..2db81c9a 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -2374,6 +2374,8 @@ void term_resize_request_completed(Terminal *term) void term_provide_backend(Terminal *term, Backend *backend) { term->backend = backend; + if (term->userpass_state) + term_userpass_state_free(term->userpass_state); if (term->backend && term->cols > 0 && term->rows > 0) backend_size(term->backend, term->cols, term->rows); }