1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

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.)
This commit is contained in:
Simon Tatham 2024-12-14 11:44:28 +00:00
parent f8e1a2b3a9
commit edd5e13ffc

View File

@ -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);
}