diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-02 12:25:02 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-02 12:25:02 +0000 |
commit | 5309651849d87300efd776395ea097df14391597 (patch) | |
tree | 3f015e3ce0d6c627f3485fd551ffb614c737e838 /libssh/options.c | |
parent | 30b02325cbb369e92e7f4ee7763afdf07aa6e78b (diff) | |
download | libssh-5309651849d87300efd776395ea097df14391597.tar.gz libssh-5309651849d87300efd776395ea097df14391597.tar.xz libssh-5309651849d87300efd776395ea097df14391597.zip |
Improve ssh_options_default_ssh_dir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@361 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/options.c')
-rw-r--r-- | libssh/options.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libssh/options.c b/libssh/options.c index 844f9f66..aab835f1 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -548,10 +548,6 @@ static char *get_username_from_uid(SSH_OPTIONS *opt, uid_t uid){ int ssh_options_default_username(SSH_OPTIONS *opt) { char *user = NULL; - if (opt == NULL) { - return -1; - } - if (opt->username) { return 0; } @@ -579,13 +575,20 @@ int ssh_options_default_username(SSH_OPTIONS *opt) { return -1; } -int ssh_options_default_ssh_dir(SSH_OPTIONS *opt){ - char buffer[256]; - if(opt->ssh_dir) - return 0; - snprintf(buffer,256,"%s/.ssh/",ssh_get_user_home_dir()); - opt->ssh_dir=strdup(buffer); +int ssh_options_default_ssh_dir(SSH_OPTIONS *opt) { + char buffer[256] = {0}; + + if (opt->ssh_dir) { return 0; + } + + snprintf(buffer, 256, "%s/.ssh/", ssh_get_user_home_dir()); + opt->ssh_dir = strdup(buffer); + if (opt->ssh_dir == NULL) { + return -1; + } + + return 0; } int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt){ |