1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

auth: Prefix kbdint functions.

This commit is contained in:
Andreas Schneider
2011-08-25 16:26:12 +02:00
parent c59939d4a2
commit 892cb92f57
4 changed files with 84 additions and 85 deletions

View File

@@ -46,9 +46,9 @@ struct ssh_kbdint_struct {
};
typedef struct ssh_kbdint_struct* ssh_kbdint;
ssh_kbdint kbdint_new(void);
void kbdint_clean(ssh_kbdint kbd);
void kbdint_free(ssh_kbdint kbd);
ssh_kbdint ssh_kbdint_new(void);
void ssh_kbdint_clean(ssh_kbdint kbd);
void ssh_kbdint_free(ssh_kbdint kbd);
#ifdef WITH_SSH1

View File

@@ -1372,10 +1372,10 @@ int ssh_userauth_agent_pubkey(ssh_session session,
}
#endif /* _WIN32 */
ssh_kbdint kbdint_new(void) {
ssh_kbdint ssh_kbdint_new(void) {
ssh_kbdint kbd;
kbd = malloc(sizeof (struct ssh_kbdint_struct));
kbd = malloc(sizeof(struct ssh_kbdint_struct));
if (kbd == NULL) {
return NULL;
}
@@ -1385,14 +1385,13 @@ ssh_kbdint kbdint_new(void) {
}
void kbdint_free(ssh_kbdint kbd) {
void ssh_kbdint_free(ssh_kbdint kbd) {
int i, n;
if (kbd == NULL) {
return;
}
SAFE_FREE(kbd->name);
SAFE_FREE(kbd->instruction);
SAFE_FREE(kbd->echo);
@@ -1418,7 +1417,7 @@ void kbdint_free(ssh_kbdint kbd) {
SAFE_FREE(kbd);
}
void kbdint_clean(ssh_kbdint kbd) {
void ssh_kbdint_clean(ssh_kbdint kbd) {
int i, n;
if (kbd == NULL) {
@@ -1551,7 +1550,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
ssh_string_free(tmp);
if (session->kbdint == NULL) {
session->kbdint = kbdint_new();
session->kbdint = ssh_kbdint_new();
if (session->kbdint == NULL) {
ssh_set_error_oom(session);
ssh_string_free(name);
@@ -1561,14 +1560,14 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
return SSH_PACKET_USED;
}
} else {
kbdint_clean(session->kbdint);
ssh_kbdint_clean(session->kbdint);
}
session->kbdint->name = ssh_string_to_char(name);
ssh_string_free(name);
if (session->kbdint->name == NULL) {
ssh_set_error_oom(session);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
leave_function();
return SSH_PACKET_USED;
}
@@ -1577,7 +1576,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
ssh_string_free(instruction);
if (session->kbdint->instruction == NULL) {
ssh_set_error_oom(session);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -1589,7 +1588,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
ssh_set_error(session, SSH_FATAL,
"Too much prompt asked from server: %u (0x%.4x)",
nprompts, nprompts);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -1601,7 +1600,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
if (session->kbdint->prompts == NULL) {
session->kbdint->nprompts = 0;
ssh_set_error_oom(session);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -1612,7 +1611,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
if (session->kbdint->echo == NULL) {
session->kbdint->nprompts = 0;
ssh_set_error_oom(session);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -1624,7 +1623,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
buffer_get_u8(packet, &session->kbdint->echo[i]);
if (tmp == NULL) {
ssh_set_error(session, SSH_FATAL, "Short INFO_REQUEST packet");
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -1634,7 +1633,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request) {
if (session->kbdint->prompts[i] == NULL) {
ssh_set_error_oom(session);
session->kbdint->nprompts = i;
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -1692,7 +1691,7 @@ static int kbdauth_send(ssh_session session) {
ssh_string_free(answer);
}
session->auth_state=SSH_AUTH_STATE_KBDINT_SENT;
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
if (packet_send(session) == SSH_ERROR) {
leave_function();

View File

@@ -706,7 +706,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
ssh_log(session, SSH_LOG_PROTOCOL, "Warning: Got a keyboard-interactive "
"response but it seems we didn't send the request.");
session->kbdint = kbdint_new();
session->kbdint = ssh_kbdint_new();
if (session->kbdint == NULL) {
ssh_set_error_oom(session);
@@ -721,7 +721,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
ssh_set_error(session, SSH_FATAL,
"Too much answers received from client: %u (0x%.4x)",
nanswers, nanswers);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -737,7 +737,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
if (session->kbdint->answers == NULL) {
session->kbdint->nanswers = 0;
ssh_set_error_oom(session);
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -749,7 +749,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
if (tmp == NULL) {
ssh_set_error(session, SSH_FATAL, "Short INFO_RESPONSE packet");
session->kbdint->nanswers = i;
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;
@@ -759,7 +759,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
if (session->kbdint->answers[i] == NULL) {
ssh_set_error_oom(session);
session->kbdint->nanswers = i;
kbdint_free(session->kbdint);
ssh_kbdint_free(session->kbdint);
session->kbdint = NULL;
leave_function();
return SSH_PACKET_USED;

View File

@@ -845,27 +845,27 @@ int ssh_message_auth_interactive_request(ssh_message msg, const char *name,
"keyboard-interactive response but it "
"seems we didn't send the request.");
msg->session->kbdint = kbdint_new();
msg->session->kbdint = ssh_kbdint_new();
if (msg->session->kbdint == NULL) {
ssh_set_error_oom(msg->session);
return SSH_ERROR;
}
} else {
kbdint_clean(msg->session->kbdint);
ssh_kbdint_clean(msg->session->kbdint);
}
msg->session->kbdint->name = strdup(name);
if(msg->session->kbdint->name == NULL) {
ssh_set_error_oom(msg->session);
kbdint_free(msg->session->kbdint);
ssh_kbdint_free(msg->session->kbdint);
msg->session->kbdint = NULL;
return SSH_PACKET_USED;
}
msg->session->kbdint->instruction = strdup(instruction);
if(msg->session->kbdint->instruction == NULL) {
ssh_set_error_oom(msg->session);
kbdint_free(msg->session->kbdint);
ssh_kbdint_free(msg->session->kbdint);
msg->session->kbdint = NULL;
return SSH_PACKET_USED;
}
@@ -876,14 +876,14 @@ int ssh_message_auth_interactive_request(ssh_message msg, const char *name,
if (msg->session->kbdint->prompts == NULL) {
msg->session->kbdint->nprompts = 0;
ssh_set_error_oom(msg->session);
kbdint_free(msg->session->kbdint);
ssh_kbdint_free(msg->session->kbdint);
msg->session->kbdint = NULL;
return SSH_ERROR;
}
msg->session->kbdint->echo = malloc(num_prompts * sizeof(char));
if (msg->session->kbdint->echo == NULL) {
ssh_set_error_oom(msg->session);
kbdint_free(msg->session->kbdint);
ssh_kbdint_free(msg->session->kbdint);
msg->session->kbdint = NULL;
return SSH_ERROR;
}
@@ -893,7 +893,7 @@ int ssh_message_auth_interactive_request(ssh_message msg, const char *name,
if (msg->session->kbdint->prompts[i] == NULL) {
ssh_set_error_oom(msg->session);
msg->session->kbdint->nprompts = i;
kbdint_free(msg->session->kbdint);
ssh_kbdint_free(msg->session->kbdint);
msg->session->kbdint = NULL;
return SSH_PACKET_USED;
}