summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-01-10 12:14:26 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2011-01-10 12:14:26 +0100
commit076dfb82942384d9839f779a986b95932a754c9e (patch)
tree2a15a66b444eb1e4d196eda431ad46cf216497d8
parentd631ce32edf658f9bf9d39be84ed2c9fab460b00 (diff)
downloadlibssh-076dfb82942384d9839f779a986b95932a754c9e.tar.gz
libssh-076dfb82942384d9839f779a986b95932a754c9e.tar.xz
libssh-076dfb82942384d9839f779a986b95932a754c9e.zip
Fix connection callbacks called at wrong time
-rw-r--r--src/client.c11
-rw-r--r--src/session.c1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/client.c b/src/client.c
index dd63a2b..7a96d6a 100644
--- a/src/client.c
+++ b/src/client.c
@@ -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'){
diff --git a/src/session.c b/src/session.c
index ef76d9f..cb6382e 100644
--- a/src/session.c
+++ b/src/session.c
@@ -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);