1
1
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Anderson Toshiyuki Sasaki 2018-07-12 13:42:23 +02:00
родитель 6e74c6c1dc
Коммит d85827f646

Просмотреть файл

@ -727,6 +727,7 @@ struct ssh_agent_state_struct {
/* Internal function */
void ssh_agent_state_free(void *data) {
struct ssh_agent_state_struct *state = data;
if (state) {
ssh_string_free_char(state->comment);
ssh_key_free(state->pubkey);
@ -760,6 +761,7 @@ int ssh_userauth_agent(ssh_session session,
const char *username) {
int rc = SSH_AUTH_ERROR;
struct ssh_agent_state_struct *state;
if (session == NULL) {
return SSH_AUTH_ERROR;
}
@ -767,6 +769,7 @@ int ssh_userauth_agent(ssh_session session,
if (!ssh_agent_is_running(session)) {
return SSH_AUTH_DENIED;
}
if (!session->agent_state) {
session->agent_state = malloc(sizeof(struct ssh_agent_state_struct));
if (!session->agent_state) {
@ -776,9 +779,11 @@ int ssh_userauth_agent(ssh_session session,
ZERO_STRUCTP(session->agent_state);
session->agent_state->state=SSH_AGENT_STATE_NONE;
}
state = session->agent_state;
if (state->pubkey == NULL)
if (state->pubkey == NULL) {
state->pubkey = ssh_agent_get_first_ident(session, &state->comment);
}
if (state->pubkey == NULL) {
return SSH_AUTH_DENIED;
@ -1283,15 +1288,19 @@ static int ssh_userauth_kbdint_init(ssh_session session,
const char *submethods)
{
int rc;
if (session->pending_call_state == SSH_PENDING_CALL_AUTH_KBDINT_INIT)
if (session->pending_call_state == SSH_PENDING_CALL_AUTH_KBDINT_INIT) {
goto pending;
}
if (session->pending_call_state != SSH_PENDING_CALL_NONE) {
ssh_set_error_invalid(session);
return SSH_ERROR;
}
rc = ssh_userauth_request_service(session);
if (rc == SSH_AGAIN)
if (rc == SSH_AGAIN) {
return SSH_AUTH_AGAIN;
}
if (rc != SSH_OK) {
return SSH_AUTH_ERROR;
}
@ -1558,8 +1567,9 @@ int ssh_userauth_kbdint(ssh_session session, const char *user,
* @returns The number of prompts.
*/
int ssh_userauth_kbdint_getnprompts(ssh_session session) {
if(session==NULL)
if (session == NULL) {
return SSH_ERROR;
}
if (session->kbdint == NULL) {
ssh_set_error_invalid(session);
return SSH_ERROR;
@ -1579,8 +1589,9 @@ int ssh_userauth_kbdint_getnprompts(ssh_session session) {
* @returns The name of the message block. Do not free it.
*/
const char *ssh_userauth_kbdint_getname(ssh_session session) {
if(session==NULL)
if (session == NULL) {
return NULL;
}
if (session->kbdint == NULL) {
ssh_set_error_invalid(session);
return NULL;
@ -1664,8 +1675,9 @@ const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i,
* @returns The number of answers.
*/
int ssh_userauth_kbdint_getnanswers(ssh_session session) {
if(session==NULL || session->kbdint == NULL)
if (session == NULL || session->kbdint == NULL) {
return SSH_ERROR;
}
return session->kbdint->nanswers;
}
@ -1711,8 +1723,9 @@ const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i) {
*/
int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i,
const char *answer) {
if (session == NULL)
if (session == NULL) {
return -1;
}
if (answer == NULL || session->kbdint == NULL ||
i >= session->kbdint->nprompts) {
ssh_set_error_invalid(session);