]> granicus.if.org Git - curl/commitdiff
ssh_connect: treat libssh2 return code better
authorDaniel Stenberg <daniel@haxx.se>
Sat, 26 Feb 2011 09:59:03 +0000 (10:59 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 26 Feb 2011 10:00:44 +0000 (11:00 +0100)
libssh2_knownhost_readfile() returns a negative value on error or
otherwise number of parsed known hosts - this was previously not
documented correctly in the libssh2 man page for the function.

Bug: http://curl.haxx.se/mail/lib-2011-02/0327.html
Reported by: murat

lib/ssh.c

index 646c9fc334b7334a2d247db23068627b349edd42..1aaa112b49d6168994795c9a48617dccc09a72e4 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2587,10 +2587,9 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
     rc = libssh2_knownhost_readfile(ssh->kh,
                                     data->set.str[STRING_SSH_KNOWNHOSTS],
                                     LIBSSH2_KNOWNHOST_FILE_OPENSSH);
-    if(rc) {
+    if(rc < 0)
       infof(data, "Failed to read known hosts from %s\n",
             data->set.str[STRING_SSH_KNOWNHOSTS]);
-    }
   }
 #endif /* HAVE_LIBSSH2_KNOWNHOST_API */