aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-04-24 22:46:19 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-04-24 22:46:19 +0200
commit6cdbc01208dad2113effda008be4f529b424a6d7 (patch)
treec8fec88adf742c1aad7d48ec194755eea403dcd8 /libssh
parent833903e8ec23977ff8dde0be10717ccec0f85202 (diff)
downloadlibssh-6cdbc01208dad2113effda008be4f529b424a6d7.tar.gz
libssh-6cdbc01208dad2113effda008be4f529b424a6d7.tar.xz
libssh-6cdbc01208dad2113effda008be4f529b424a6d7.zip
Fixes infinite loops
Thanks to Xi Wang for the patches
Diffstat (limited to 'libssh')
-rw-r--r--libssh/auth.c3
-rw-r--r--libssh/auth1.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/libssh/auth.c b/libssh/auth.c
index b0e0e90..3961f78 100644
--- a/libssh/auth.c
+++ b/libssh/auth.c
@@ -218,7 +218,8 @@ static int wait_auth_status(ssh_session session) {
enter_function();
while (session->auth_state == SSH_AUTH_STATE_NONE) {
- ssh_handle_packets(session,-1);
+ if (ssh_handle_packets(session,-1) != SSH_OK)
+ break;
}
switch(session->auth_state){
case SSH_AUTH_STATE_ERROR:
diff --git a/libssh/auth1.c b/libssh/auth1.c
index 3571d76..4154728 100644
--- a/libssh/auth1.c
+++ b/libssh/auth1.c
@@ -38,7 +38,8 @@ static int wait_auth1_status(ssh_session session) {
enter_function();
/* wait for a packet */
while(session->auth_state == SSH_AUTH_STATE_NONE)
- ssh_handle_packets(session,-1);
+ if (ssh_handle_packets(session,-1) != SSH_OK)
+ break;
ssh_log(session,SSH_LOG_PROTOCOL,"Auth state : %d",session->auth_state);
leave_function();
switch(session->auth_state) {
@@ -57,9 +58,10 @@ void ssh_auth1_handler(ssh_session session, uint8_t type){
ssh_set_error(session,SSH_FATAL,"SSH_SMSG_SUCCESS or FAILED received in wrong state");
return;
}
- if(type==SSH_SMSG_SUCCESS)
+ if(type==SSH_SMSG_SUCCESS){
session->auth_state=SSH_AUTH_STATE_SUCCESS;
- if(type==SSH_SMSG_FAILURE)
+ session->session_state=SSH_SESSION_STATE_AUTHENTICATED;
+ } else if(type==SSH_SMSG_FAILURE)
session->auth_state=SSH_AUTH_STATE_FAILED;
}