mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 18:28:10 +09:00
auth: Fix memory leak in ssh_userauth_publickey_auto()
When a key is rejected, free the allocated memory before returning. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
46c54e5ddb
commit
6bd2b93f43
@@ -1132,7 +1132,9 @@ int ssh_userauth_publickey_auto(ssh_session session,
|
|||||||
"Public key authentication error for %s",
|
"Public key authentication error for %s",
|
||||||
privkey_file);
|
privkey_file);
|
||||||
ssh_key_free(state->privkey);
|
ssh_key_free(state->privkey);
|
||||||
|
state->privkey = NULL;
|
||||||
ssh_key_free(state->pubkey);
|
ssh_key_free(state->pubkey);
|
||||||
|
state->pubkey = NULL;
|
||||||
SAFE_FREE(session->auth.auto_state);
|
SAFE_FREE(session->auth.auto_state);
|
||||||
return rc;
|
return rc;
|
||||||
} else if (rc == SSH_AUTH_AGAIN) {
|
} else if (rc == SSH_AUTH_AGAIN) {
|
||||||
@@ -1198,6 +1200,9 @@ int ssh_userauth_publickey_auto(ssh_session session,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssh_key_free(state->privkey);
|
||||||
|
ssh_key_free(state->pubkey);
|
||||||
|
|
||||||
SSH_LOG(SSH_LOG_WARN,
|
SSH_LOG(SSH_LOG_WARN,
|
||||||
"The server accepted the public key but refused the signature");
|
"The server accepted the public key but refused the signature");
|
||||||
state->it = state->it->next;
|
state->it = state->it->next;
|
||||||
|
|||||||
Reference in New Issue
Block a user