1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

client: fix corner case when sockets are manually created

If the sockets are created manually and passed to libssh the internal session
state is set to SSH_SESSION_STATE_SOCKET_CONNECTED. Result of this fix can be
verified by running torture_connect test (torture_connect_socket) with -vvvv
flags.

Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Luka Perkov
2014-03-17 16:16:07 +01:00
committed by Andreas Schneider
parent 9423a3a065
commit dbb2de272b

View File

@@ -60,12 +60,15 @@
static void socket_callback_connected(int code, int errno_code, void *user){
ssh_session session=(ssh_session)user;
if(session->session_state != SSH_SESSION_STATE_CONNECTING){
if (session->session_state != SSH_SESSION_STATE_CONNECTING &&
session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED)
{
ssh_set_error(session,SSH_FATAL, "Wrong state in socket_callback_connected : %d",
session->session_state);
return;
}
SSH_LOG(SSH_LOG_RARE,"Socket connection callback: %d (%d)",code, errno_code);
if(code == SSH_SOCKET_CONNECTED_OK)
session->session_state=SSH_SESSION_STATE_SOCKET_CONNECTED;