mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
auth: Avoid memory leaks during agent authentication
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
This commit is contained in:
@@ -1014,6 +1014,7 @@ int ssh_userauth_agent(ssh_session session,
|
|||||||
"not listed in config, skipping", state->comment);
|
"not listed in config, skipping", state->comment);
|
||||||
SSH_STRING_FREE_CHAR(state->comment);
|
SSH_STRING_FREE_CHAR(state->comment);
|
||||||
state->comment = NULL;
|
state->comment = NULL;
|
||||||
|
SSH_KEY_FREE(state->pubkey);
|
||||||
state->pubkey = ssh_agent_get_next_ident(
|
state->pubkey = ssh_agent_get_next_ident(
|
||||||
session, &state->comment);
|
session, &state->comment);
|
||||||
|
|
||||||
@@ -1039,7 +1040,7 @@ int ssh_userauth_agent(ssh_session session,
|
|||||||
"Public key of %s refused by server", state->comment);
|
"Public key of %s refused by server", state->comment);
|
||||||
SSH_STRING_FREE_CHAR(state->comment);
|
SSH_STRING_FREE_CHAR(state->comment);
|
||||||
state->comment = NULL;
|
state->comment = NULL;
|
||||||
ssh_key_free(state->pubkey);
|
SSH_KEY_FREE(state->pubkey);
|
||||||
state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
|
state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
|
||||||
state->state = SSH_AGENT_STATE_NONE;
|
state->state = SSH_AGENT_STATE_NONE;
|
||||||
continue;
|
continue;
|
||||||
@@ -1063,7 +1064,7 @@ int ssh_userauth_agent(ssh_session session,
|
|||||||
} else if (rc != SSH_AUTH_SUCCESS) {
|
} else if (rc != SSH_AUTH_SUCCESS) {
|
||||||
SSH_LOG(SSH_LOG_DEBUG,
|
SSH_LOG(SSH_LOG_DEBUG,
|
||||||
"Server accepted public key but refused the signature");
|
"Server accepted public key but refused the signature");
|
||||||
ssh_key_free(state->pubkey);
|
SSH_KEY_FREE(state->pubkey);
|
||||||
state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
|
state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
|
||||||
state->state = SSH_AGENT_STATE_NONE;
|
state->state = SSH_AGENT_STATE_NONE;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user