aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Housley <jim@thehousleys.net>2007-06-20 11:30:35 +0000
committerJames Housley <jim@thehousleys.net>2007-06-20 11:30:35 +0000
commit6e7f47da5b2e44f799f2c49a96f8764a715ea423 (patch)
treea4197a28ac684351320f45ced6d194fc9cdcc3c7 /lib
parent277bab0c7b7f308dbe38e272ff6914fffa4c524e (diff)
If the creation of rsa and rsa_pub fail due to memory, don't try
other authentication methods. Terminate with a memory error.
Diffstat (limited to 'lib')
-rw-r--r--lib/ssh.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index a79904b8e..484103f34 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -384,35 +384,37 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
sshc->rsa_pub = aprintf("%s", data->set.ssh_public_key);
else if (home)
sshc->rsa_pub = aprintf("%s/.ssh/id_dsa.pub", home);
+
+ if (sshc->rsa_pub == NULL) {
+ curl_free(home);
+ state(conn, SSH_SESSION_FREE);
+ sshc->actualCode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
if (data->set.ssh_private_key)
sshc->rsa = aprintf("%s", data->set.ssh_private_key);
else if (home)
sshc->rsa = aprintf("%s/.ssh/id_dsa", home);
+ if (sshc->rsa == NULL) {
+ curl_free(home);
+ curl_free(sshc->rsa_pub);
+ state(conn, SSH_SESSION_FREE);
+ sshc->actualCode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+
sshc->passphrase = data->set.key_passwd;
if (!sshc->passphrase)
sshc->passphrase = "";
curl_free(home);
- if (sshc->rsa_pub) {
- infof(conn->data, "Using ssh public key file %s\n", sshc->rsa_pub);
- }
- if (sshc->rsa) {
- infof(conn->data, "Using ssh private key file %s\n", sshc->rsa);
- }
-
- if (sshc->rsa_pub && sshc->rsa) {
- state(conn, SSH_AUTH_PKEY);
- } else {
- /* One or both aprint()'s might have failed,
- move on to password authentication */
- curl_free(sshc->rsa_pub);
- curl_free(sshc->rsa);
+ infof(conn->data, "Using ssh public key file %s\n", sshc->rsa_pub);
+ infof(conn->data, "Using ssh private key file %s\n", sshc->rsa);
- state(conn, SSH_AUTH_PASS_INIT);
- }
+ state(conn, SSH_AUTH_PKEY);
} else {
state(conn, SSH_AUTH_PASS_INIT);
}