aboutsummaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-09-02 13:58:37 +0300
committerAris Adamantiadis <aris@0xbadc0de.be>2011-09-02 13:58:37 +0300
commit20f8e73e3eaf8d7f69786db3f6385095e244e85c (patch)
tree1fba85badc6b95baceda20f4871735eac6a2404b /src/server.c
parentef5701a5357e3f5b71aa5c387e4f976fe5df0ab7 (diff)
downloadlibssh-20f8e73e3eaf8d7f69786db3f6385095e244e85c.tar.gz
libssh-20f8e73e3eaf8d7f69786db3f6385095e244e85c.tar.xz
libssh-20f8e73e3eaf8d7f69786db3f6385095e244e85c.zip
Update libssh to ssh_handle_packets_termination
cherry-picked from 0cb5248 Should resolve all timeout problems Conflicts: src/auth.c src/channels.c
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/server.c b/src/server.c
index 5b2ccee8..5ca036f3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -452,10 +452,22 @@ static int callback_receive_banner(const void *data, size_t len, void *user) {
return ret;
}
+/* returns 0 until the key exchange is not finished */
+static int ssh_server_kex_termination(void *s){
+ ssh_session session = s;
+ if (session->session_state != SSH_SESSION_STATE_ERROR &&
+ session->session_state != SSH_SESSION_STATE_AUTHENTICATING &&
+ session->session_state != SSH_SESSION_STATE_DISCONNECTED)
+ return 0;
+ else
+ return 1;
+}
+
/* Do the banner and key exchange */
int ssh_handle_key_exchange(ssh_session session) {
int rc;
-
+ if (session->session_state != SSH_SESSION_STATE_NONE)
+ goto pending;
rc = ssh_send_banner(session, 1);
if (rc < 0) {
return SSH_ERROR;
@@ -474,22 +486,16 @@ int ssh_handle_key_exchange(ssh_session session) {
if (rc < 0) {
return SSH_ERROR;
}
-
- while (session->session_state != SSH_SESSION_STATE_ERROR &&
- session->session_state != SSH_SESSION_STATE_AUTHENTICATING &&
- session->session_state != SSH_SESSION_STATE_DISCONNECTED) {
- /*
- * loop until SSH_SESSION_STATE_BANNER_RECEIVED or
- * SSH_SESSION_STATE_ERROR
- */
- ssh_handle_packets(session, -2);
- ssh_log(session,SSH_LOG_PACKET, "ssh_handle_key_exchange: Actual state : %d",
- session->session_state);
- }
-
+ pending:
+ rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
+ ssh_server_kex_termination,session);
+ ssh_log(session,SSH_LOG_PACKET, "ssh_handle_key_exchange: Actual state : %d",
+ session->session_state);
+ if (rc != SSH_OK)
+ return rc;
if (session->session_state == SSH_SESSION_STATE_ERROR ||
session->session_state == SSH_SESSION_STATE_DISCONNECTED) {
- return SSH_ERROR;
+ return SSH_ERROR;
}
return SSH_OK;