aboutsummaryrefslogtreecommitdiff
path: root/libssh/options.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-02 12:14:27 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-02 12:14:27 +0000
commit3f4c1976fd19bf3cd47502b422c691b6d4b1ed12 (patch)
treebbd446293c931d4b2e66f41812328b604f1db1c7 /libssh/options.c
parenta459a8b4dbc9b391b6080fcdc0a38ca32a3f6a4c (diff)
downloadlibssh-3f4c1976fd19bf3cd47502b422c691b6d4b1ed12.tar.gz
libssh-3f4c1976fd19bf3cd47502b422c691b6d4b1ed12.tar.xz
libssh-3f4c1976fd19bf3cd47502b422c691b6d4b1ed12.zip
Improve ssh_options_set_banner().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@358 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/options.c')
-rw-r--r--libssh/options.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/libssh/options.c b/libssh/options.c
index 6f8e907..2696f6e 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -456,14 +456,27 @@ void ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey){
opt->rsakey=strdup(rsakey);
}
-/** \brief set the server banner sent to clients
- * \param opt options structure
- * \param banner a text banner to be shown
+/**
+ * @brief Set the server banner sent to clients.
+ *
+ * @param opt The options structure to use.
+ *
+ * @param banner A text banner to be shown.
+ *
+ * @return 0 on success, < 0 on error.
*/
-void ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner){
- if(opt->banner)
- free(opt->banner);
- opt->banner=strdup(banner);
+int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner) {
+ if (opt == NULL || banner == NULL) {
+ return -1;
+ }
+
+ SAFE_FREE(opt->banner);
+ opt->banner = strdup(banner);
+ if (opt->banner == NULL) {
+ return -1;
+ }
+
+ return 0;
}
/** the methods are:\n