SSH: three state machine fixups

The SSH state machine didn't clear the 'rc' variable appropriately in a
two places which prevented it from looping the way it should. And it
lacked an 'else' statement that made it possible to erroneously get
stuck in the SSH_AUTH_AGENT state.

Reported-by: Tim Stack

Closes #357
This commit is contained in:
Daniel Stenberg 2015-08-02 22:50:31 +02:00
parent 3b4ee0d432
commit c4eb10e2f0
1 changed files with 7 additions and 4 deletions

View File

@ -935,6 +935,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
} }
else { else {
state(conn, SSH_AUTH_HOST_INIT); state(conn, SSH_AUTH_HOST_INIT);
rc = 0; /* clear rc and continue */
} }
break; break;
@ -1019,11 +1020,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->sshagent_identity); sshc->sshagent_identity);
if(rc < 0) { if(rc < 0) {
if(rc != LIBSSH2_ERROR_EAGAIN) { if(rc != LIBSSH2_ERROR_EAGAIN)
/* tried and failed? go to next identity */ /* tried and failed? go to next identity */
sshc->sshagent_prev_identity = sshc->sshagent_identity; sshc->sshagent_prev_identity = sshc->sshagent_identity;
} else
break; break;
} }
} }
@ -1037,8 +1038,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
infof(data, "Agent based authentication successful\n"); infof(data, "Agent based authentication successful\n");
state(conn, SSH_AUTH_DONE); state(conn, SSH_AUTH_DONE);
} }
else else {
state(conn, SSH_AUTH_KEY_INIT); state(conn, SSH_AUTH_KEY_INIT);
rc = 0; /* clear rc and continue */
}
#endif #endif
break; break;