mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
auth: Don't fail in publickey_auto if we can't read the key.
We should go on and try the next one as it was before. Also make sure we don't leak memory ;)
This commit is contained in:
@@ -1103,6 +1103,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
|
|||||||
SSH_FATAL,
|
SSH_FATAL,
|
||||||
"Failed to read private key: %s",
|
"Failed to read private key: %s",
|
||||||
privkey_file);
|
privkey_file);
|
||||||
|
continue;
|
||||||
return SSH_AUTH_ERROR;
|
return SSH_AUTH_ERROR;
|
||||||
} else if (rc == SSH_EOF) {
|
} else if (rc == SSH_EOF) {
|
||||||
/* If the file doesn't exist, continue */
|
/* If the file doesn't exist, continue */
|
||||||
@@ -1155,13 +1156,15 @@ int ssh_userauth_publickey_auto(ssh_session session,
|
|||||||
auth_data,
|
auth_data,
|
||||||
&privkey);
|
&privkey);
|
||||||
if (rc == SSH_ERROR) {
|
if (rc == SSH_ERROR) {
|
||||||
|
ssh_key_free(pubkey);
|
||||||
ssh_set_error(session,
|
ssh_set_error(session,
|
||||||
SSH_FATAL,
|
SSH_FATAL,
|
||||||
"Failed to read private key: %s",
|
"Failed to read private key: %s",
|
||||||
privkey_file);
|
privkey_file);
|
||||||
return SSH_AUTH_ERROR;
|
continue;
|
||||||
} else if (rc == SSH_EOF) {
|
} else if (rc == SSH_EOF) {
|
||||||
/* If the file doesn't exist, continue */
|
/* If the file doesn't exist, continue */
|
||||||
|
ssh_key_free(pubkey);
|
||||||
ssh_log(session,
|
ssh_log(session,
|
||||||
SSH_LOG_PACKET,
|
SSH_LOG_PACKET,
|
||||||
"Private key %s doesn't exist.",
|
"Private key %s doesn't exist.",
|
||||||
|
|||||||
Reference in New Issue
Block a user