summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libssh/libssh.h2
-rw-r--r--libssh/options.c31
2 files changed, 23 insertions, 10 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 8115871..9049a78 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -322,7 +322,7 @@ int ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
(void *arg, float status), void *arg);
int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
-void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
+int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
void ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);
void ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey);
void ssh_options_set_log_function(SSH_OPTIONS *opt,
diff --git a/libssh/options.c b/libssh/options.c
index 11333ee..66870c8 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -691,16 +691,29 @@ int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow) {
return 0;
}
-/** Default value is 1 (allow connection to SSH2 servers)
- * \brief allow or deny the connection to SSH2 servers
- * \param opt options structure
- * \param allow nonzero values allow ssh2
+/**
+ * @brief Allow or deny the connection to SSH2 servers.
+ *
+ * Default value is 1 (allow connection to SSH2 servers).
+ *
+ * @param opt The options structure to use.
+ *
+ * @param allow Non zero values allow ssh2.
+ *
+ * @return 0 on success, < 0 on error.
*/
-void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow){
- if(allow)
- opt->ssh2allowed=1;
- else
- opt->ssh2allowed=0;
+int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow) {
+ if (opt == NULL) {
+ return -1;
+ }
+
+ if (allow) {
+ opt->ssh2allowed = 1;
+ } else {
+ opt->ssh2allowed = 0;
+ }
+
+ return 0;
}
/** Default is a write on stderr