aboutsummaryrefslogtreecommitdiff
path: root/src/auth.c
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2011-05-02 17:30:43 +0200
committermilo <milo@r0ot.me>2011-05-02 17:30:43 +0200
commitb6e712e934a45981b3a12cb67b48df006402a4d7 (patch)
treebced5a27bee4f5aa91ef608e32aa36ca2759a8ee /src/auth.c
parent7d2064c2894fc298cc8923cae657200900b032e5 (diff)
downloadlibssh-b6e712e934a45981b3a12cb67b48df006402a4d7.tar.gz
libssh-b6e712e934a45981b3a12cb67b48df006402a4d7.tar.xz
libssh-b6e712e934a45981b3a12cb67b48df006402a4d7.zip
Fix segfault when ssh_userauth_kbdint_setanswer() has not been called
Diffstat (limited to 'src/auth.c')
-rw-r--r--src/auth.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/auth.c b/src/auth.c
index 13033d18..67376781 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -1828,6 +1828,11 @@ static int kbdauth_send(ssh_session session) {
enter_function();
+ if(session==NULL || session->kbdint == NULL
+ || session->kbdint->answers == NULL) {
+ return rc;
+ }
+
if (buffer_add_u8(session->out_buffer, SSH2_MSG_USERAUTH_INFO_RESPONSE) < 0 ||
buffer_add_u32(session->out_buffer,
htonl(session->kbdint->nprompts)) < 0) {
@@ -2067,8 +2072,10 @@ int ssh_userauth_kbdint_getnanswers(ssh_session session) {
* @return 0 on success, < 0 on error.
*/
const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i) {
- if(session==NULL || session->kbdint == NULL)
+ if(session==NULL || session->kbdint == NULL
+ || session->kbdint->answers == NULL) {
return NULL;
+ }
if (i > session->kbdint->nanswers) {
return NULL;
}