summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libssh/server.h2
-rw-r--r--libssh/messages.c24
2 files changed, 20 insertions, 6 deletions
diff --git a/include/libssh/server.h b/include/libssh/server.h
index 76a64f0..477f9d7 100644
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -80,7 +80,7 @@ void ssh_message_free(SSH_MESSAGE *msg);
char *ssh_message_auth_user(SSH_MESSAGE *msg);
char *ssh_message_auth_password(SSH_MESSAGE *msg);
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
-void ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
+int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
diff --git a/libssh/messages.c b/libssh/messages.c
index 1fdf685..65d9550 100644
--- a/libssh/messages.c
+++ b/libssh/messages.c
@@ -211,16 +211,30 @@ error:
return NULL;
}
-char *ssh_message_auth_user(SSH_MESSAGE *msg){
- return msg->auth_request.username;
+char *ssh_message_auth_user(SSH_MESSAGE *msg) {
+ if (msg == NULL || msg->auth_request == NULL) {
+ return NULL;
+ }
+
+ return msg->auth_request.username;
}
char *ssh_message_auth_password(SSH_MESSAGE *msg){
- return msg->auth_request.password;
+ if (msg == NULL || msg->auth_request == NULL) {
+ return NULL;
+ }
+
+ return msg->auth_request.password;
}
-void ssh_message_auth_set_methods(SSH_MESSAGE *msg,int methods){
- msg->session->auth_methods=methods;
+int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods) {
+ if (msg == NULL || msg->session == NULL) {
+ return -1;
+ }
+
+ msg->session->auth_methods = methods;
+
+ return 0;
}
static int ssh_message_auth_reply_default(SSH_MESSAGE *msg,int partial){