From be538e07667e1ba880b7201014be706851428d40 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 15 Jan 2016 10:27:33 +0100 Subject: ssh: make CURLOPT_SSH_PUBLIC_KEYFILE treat "" as NULL The CURLOPT_SSH_PUBLIC_KEYFILE option has been documented to handle empty strings specially since curl-7_25_0-31-g05a443a but the behavior was unintentionally removed in curl-7_38_0-47-gfa7d04f. This commit restores the original behavior and clarifies it in the documentation that NULL and "" have both the same meaning when passed to CURLOPT_SSH_PUBLIC_KEYFILE. Bug: http://curl.haxx.se/mail/lib-2016-01/0072.html --- lib/ssh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/ssh.c') diff --git a/lib/ssh.c b/lib/ssh.c index f9bbdf104..198a230af 100644 --- a/lib/ssh.c +++ b/lib/ssh.c @@ -848,7 +848,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) * libssh2 extract the public key from the private key file. * This is done by simply passing sshc->rsa_pub = NULL. */ - if(data->set.str[STRING_SSH_PUBLIC_KEY]) { + if(data->set.str[STRING_SSH_PUBLIC_KEY] + /* treat empty string the same way as NULL */ + && data->set.str[STRING_SSH_PUBLIC_KEY][0]) { sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); if(!sshc->rsa_pub) out_of_memory = TRUE; @@ -869,7 +871,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) free(home); - infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub); + if(sshc->rsa_pub) + infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub); infof(data, "Using SSH private key file '%s'\n", sshc->rsa); state(conn, SSH_AUTH_PKEY); -- cgit v1.2.3