diff options
author | Anderson Toshiyuki Sasaki <ansasaki@redhat.com> | 2020-03-02 11:36:18 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2020-03-29 09:58:19 +0200 |
commit | 6bd2b93f43dacceaf060d1aeb89749eba7df2cbb (patch) | |
tree | b42306a197534bc0f52d5e044433dd0324e79e6d | |
parent | 46c54e5ddb361818d9e1d383493091b0ea620cfa (diff) | |
download | libssh-6bd2b93f43dacceaf060d1aeb89749eba7df2cbb.tar.gz libssh-6bd2b93f43dacceaf060d1aeb89749eba7df2cbb.tar.xz libssh-6bd2b93f43dacceaf060d1aeb89749eba7df2cbb.zip |
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>
-rw-r--r-- | src/auth.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -1132,7 +1132,9 @@ int ssh_userauth_publickey_auto(ssh_session session, "Public key authentication error for %s", privkey_file); ssh_key_free(state->privkey); + state->privkey = NULL; ssh_key_free(state->pubkey); + state->pubkey = NULL; SAFE_FREE(session->auth.auto_state); return rc; } else if (rc == SSH_AUTH_AGAIN) { @@ -1198,6 +1200,9 @@ int ssh_userauth_publickey_auto(ssh_session session, return rc; } + ssh_key_free(state->privkey); + ssh_key_free(state->pubkey); + SSH_LOG(SSH_LOG_WARN, "The server accepted the public key but refused the signature"); state->it = state->it->next; |