aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libssh/callbacks.h2
-rw-r--r--include/libssh/legacy.h2
-rw-r--r--libssh/callbacks.c12
3 files changed, 12 insertions, 4 deletions
diff --git a/include/libssh/callbacks.h b/include/libssh/callbacks.h
index 3ceb385..589c0ae 100644
--- a/include/libssh/callbacks.h
+++ b/include/libssh/callbacks.h
@@ -244,7 +244,7 @@ typedef struct ssh_packet_callbacks_struct *ssh_packet_callbacks;
*
* @param cb The callback itself.
*
- * @return 0 on success, < 0 on error.
+ * @return SSH_OK on success, SSH_ERROR on error.
*/
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);
diff --git a/include/libssh/legacy.h b/include/libssh/legacy.h
index 33ed357..7d2d582 100644
--- a/include/libssh/legacy.h
+++ b/include/libssh/legacy.h
@@ -22,6 +22,8 @@
/* Since libssh.h includes legacy.h, it's important that libssh.h is included
* first. we don't define LEGACY_H now because we want it to be defined when
* included from libssh.h
+ * All function calls declared in this header are deprecated and meant to be
+ * removed in future.
*/
#include "libssh/libssh.h"
diff --git a/libssh/callbacks.c b/libssh/callbacks.c
index 7553ca6..1568d51 100644
--- a/libssh/callbacks.c
+++ b/libssh/callbacks.c
@@ -28,10 +28,16 @@
int ssh_set_callbacks(ssh_session session, ssh_callbacks cb) {
if (session == NULL || cb == NULL) {
- return -1;
+ return SSH_ERROR;
+ }
+ enter_function();
+ if(cb->size <= 0 || cb->size > 1024 * sizeof(void *)){
+ ssh_set_error(session,SSH_FATAL,
+ "Invalid callback passed in (badly initialized)");
+ leave_function();
+ return SSH_ERROR;
}
-
session->callbacks = cb;
-
+ leave_function();
return 0;
}