From eedecd02694cfba2796c79496e1d6c9ebc7ea97a Mon Sep 17 00:00:00 2001 From: Joseph Southwell Date: Sun, 2 Feb 2014 19:25:16 +0100 Subject: [PATCH] client: Fix EOF session error reporting. Reviewed-by: Andreas Schneider --- src/client.c | 3 ++- src/session.c | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client.c b/src/client.c index 2c9cc21a..a095fec5 100644 --- a/src/client.c +++ b/src/client.c @@ -544,7 +544,8 @@ pending: } SSH_LOG(SSH_LOG_PACKET,"Actual timeout : %d", timeout); ret = ssh_handle_packets_termination(session, timeout, ssh_connect_termination, session); - if (ret == SSH_ERROR || !ssh_connect_termination(session)) { + if (session->session_state != SSH_SESSION_STATE_ERROR && + (ret == SSH_ERROR || !ssh_connect_termination(session))) { ssh_set_error(session, SSH_FATAL, "Timeout connecting to %s", session->opts.host); session->session_state = SSH_SESSION_STATE_ERROR; diff --git a/src/session.c b/src/session.c index 1128791e..b26eb969 100644 --- a/src/session.c +++ b/src/session.c @@ -695,8 +695,13 @@ void ssh_socket_exception_callback(int code, int errno_code, void *user){ ssh_session session=(ssh_session)user; SSH_LOG(SSH_LOG_RARE,"Socket exception callback: %d (%d)",code, errno_code); - session->session_state=SSH_SESSION_STATE_ERROR; - ssh_set_error(session,SSH_FATAL,"Socket error: %s",strerror(errno_code)); + session->session_state = SSH_SESSION_STATE_ERROR; + if (errno_code == 0 && code == SSH_SOCKET_EXCEPTION_EOF) { + ssh_set_error(session, SSH_FATAL, "Socket error: disconnected"); + } else { + ssh_set_error(session, SSH_FATAL, "Socket error: %s", strerror(errno_code)); + } + session->ssh_connection_callback(session); }