From c912d0936d94c7aacf8698965562743f5f5fa933 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 27 Sep 2018 17:47:55 +0100 Subject: [PATCH] Handle error messages even before session startup. I carefully put a flag in the new Ssh structure so that I could tell the difference between ssh->base_layer being NULL because it hasn't been set up yet, and being NULL because it's been and gone and the session is terminated. And did I check that flag in all the error routines? I did not. Result: an early socket error, while we're still in the verstring BPP, doesn't get reported as an error message and doesn't cause the socket to be cleaned up. --- ssh.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ssh.c b/ssh.c index e52b230f..20e9bff7 100644 --- a/ssh.c +++ b/ssh.c @@ -387,7 +387,7 @@ static void ssh_initiate_connection_close(Ssh ssh) void ssh_remote_error(Ssh ssh, const char *fmt, ...) { - if (ssh->base_layer) { + if (ssh->base_layer || !ssh->session_started) { GET_FORMATTED_MSG; /* Error messages sent by the remote don't count as clean exits */ @@ -405,7 +405,7 @@ void ssh_remote_error(Ssh ssh, const char *fmt, ...) void ssh_remote_eof(Ssh ssh, const char *fmt, ...) { - if (ssh->base_layer) { + if (ssh->base_layer || !ssh->session_started) { GET_FORMATTED_MSG; /* EOF from the remote, if we were expecting it, does count as @@ -428,7 +428,7 @@ void ssh_remote_eof(Ssh ssh, const char *fmt, ...) void ssh_proto_error(Ssh ssh, const char *fmt, ...) { - if (ssh->base_layer) { + if (ssh->base_layer || !ssh->session_started) { GET_FORMATTED_MSG; ssh->exitcode = 128; @@ -445,7 +445,7 @@ void ssh_proto_error(Ssh ssh, const char *fmt, ...) void ssh_sw_abort(Ssh ssh, const char *fmt, ...) { - if (ssh->base_layer) { + if (ssh->base_layer || !ssh->session_started) { GET_FORMATTED_MSG; ssh->exitcode = 128; @@ -462,7 +462,7 @@ void ssh_sw_abort(Ssh ssh, const char *fmt, ...) void ssh_user_close(Ssh ssh, const char *fmt, ...) { - if (ssh->base_layer) { + if (ssh->base_layer || !ssh->session_started) { GET_FORMATTED_MSG; /* Closing the connection due to user action, even if the