summaryrefslogtreecommitdiffstats
path: root/libssh/options.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-02 12:26:44 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-02 12:26:44 +0000
commitcfea89fb7c7fe8482e3a6fadbd6595f2d552ed87 (patch)
treef8b4bb4e2d17ac9ee35f0a18ef264d8ac6cb0427 /libssh/options.c
parent5309651849d87300efd776395ea097df14391597 (diff)
downloadlibssh-cfea89fb7c7fe8482e3a6fadbd6595f2d552ed87.tar.gz
libssh-cfea89fb7c7fe8482e3a6fadbd6595f2d552ed87.tar.xz
libssh-cfea89fb7c7fe8482e3a6fadbd6595f2d552ed87.zip
Improve ssh_options_default_known_hosts_file().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@362 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/options.c')
-rw-r--r--libssh/options.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/libssh/options.c b/libssh/options.c
index aab835f..ede7ebf 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -591,14 +591,24 @@ int ssh_options_default_ssh_dir(SSH_OPTIONS *opt) {
return 0;
}
-int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt){
- char buffer[1024];
- if(opt->known_hosts_file)
- return 0;
- ssh_options_default_ssh_dir(opt);
- snprintf(buffer,1024,"%s/known_hosts",opt->ssh_dir);
- opt->known_hosts_file=strdup(buffer);
+int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt) {
+ char buffer[1024] = {0};
+
+ if (opt->known_hosts_file) {
return 0;
+ }
+
+ if (ssh_options_default_ssh_dir(opt) < 0) {
+ return -1;
+ }
+
+ snprintf(buffer, 1024, "%s/known_hosts", opt->ssh_dir);
+ opt->known_hosts_file = strdup(buffer);
+ if (opt->known_hosts_file == NULL) {
+ return -1;
+ }
+
+ return 0;
}
/** During ssh_connect(), libssh will call the callback with status from