Skip to content

Commit c310d35

Browse files
authored
Merge pull request #69 from rovarga/kbd-int
Do not send extra ssh_message_reply_default()
2 parents 1b1d2a5 + ad7a553 commit c310d35

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/session_server_ssh.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,19 +855,26 @@ nc_sshcb_auth_kbdint(struct nc_session *session, ssh_message msg)
855855
char echo[] = {0};
856856

857857
ssh_message_auth_interactive_request(msg, "Interactive SSH Authentication", "Type your password:", 1, prompts, echo);
858+
auth_ret = -1;
858859
} else {
859860
if (ssh_userauth_kbdint_getnanswers(session->ti.libssh.session) != 1) {// failed session
860861
ssh_message_reply_default(msg);
861862
return;
862863
}
863864
pass_hash = auth_password_get_pwd_hash(session->username);// get hashed password
864865
if (pass_hash) {
865-
auth_ret = auth_password_compare_pwd(pass_hash, ssh_userauth_kbdint_getanswer(session->ti.libssh.session, 0));
866+
/* Normalize auth_password_compare_pwd result to 0 or 1 */
867+
auth_ret = !!auth_password_compare_pwd(pass_hash, ssh_userauth_kbdint_getanswer(session->ti.libssh.session, 0));
866868
free(pass_hash);// free hashed password
867869
}
868870
}
869871
}
870872

873+
/* We have already sent a reply */
874+
if (auth_ret == -1) {
875+
return;
876+
}
877+
871878
/* Authenticate message based on outcome */
872879
if (!auth_ret) {
873880
session->flags |= NC_SESSION_SSH_AUTHENTICATED;

0 commit comments

Comments
 (0)