]> granicus.if.org Git - curl/commitdiff
SSH: three state machine fixups
authorDaniel Stenberg <daniel@haxx.se>
Sun, 2 Aug 2015 20:50:31 +0000 (22:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 2 Aug 2015 20:50:31 +0000 (22:50 +0200)
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

lib/ssh.c

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