1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-25 03:41:56 +03:00

Fix connection callbacks called at wrong time

This commit is contained in:
Aris Adamantiadis
2011-01-10 12:14:26 +01:00
parent d631ce32ed
commit 076dfb8294
2 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,12 @@
static void socket_callback_connected(int code, int errno_code, void *user){
ssh_session session=(ssh_session)user;
enter_function();
if(session->session_state != SSH_SESSION_STATE_CONNECTING){
ssh_set_error(session,SSH_FATAL, "Wrong state in socket_callback_connected : %d",
session->session_state);
leave_function();
return;
}
ssh_log(session,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;
@ -84,6 +90,11 @@ static int callback_receive_banner(const void *data, size_t len, void *user) {
size_t i;
int ret=0;
enter_function();
if(session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED){
ssh_set_error(session,SSH_FATAL,"Wrong state in callback_receive_banner : %d",session->session_state);
leave_function();
return SSH_ERROR;
}
for(i=0;i<len;++i){
#ifdef WITH_PCAP
if(session->pcap_ctx && buffer[i] == '\n'){

View File

@ -370,7 +370,6 @@ int ssh_handle_packets(ssh_session session, int timeout) {
enter_function();
spoll_in=ssh_socket_get_poll_handle_in(session->socket);
spoll_out=ssh_socket_get_poll_handle_out(session->socket);
ssh_poll_add_events(spoll_in, POLLIN | POLLERR);
ctx=ssh_poll_get_ctx(spoll_in);
if(ctx==NULL){
ctx=ssh_poll_get_default_ctx(session);