mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
auth: Fix freeing memory in ssh_userauth_agent_publickey()
CID 1395453 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
22
src/auth.c
22
src/auth.c
@@ -693,7 +693,8 @@ static int ssh_userauth_agent_publickey(ssh_session session,
|
|||||||
const char *username,
|
const char *username,
|
||||||
ssh_key pubkey)
|
ssh_key pubkey)
|
||||||
{
|
{
|
||||||
ssh_string str = NULL;
|
ssh_string pubkey_s = NULL;
|
||||||
|
ssh_string sig_blob = NULL;
|
||||||
const char *sig_type_c = NULL;
|
const char *sig_type_c = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -717,7 +718,7 @@ static int ssh_userauth_agent_publickey(ssh_session session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* public key */
|
/* public key */
|
||||||
rc = ssh_pki_export_pubkey_blob(pubkey, &str);
|
rc = ssh_pki_export_pubkey_blob(pubkey, &pubkey_s);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -729,7 +730,7 @@ static int ssh_userauth_agent_publickey(ssh_session session,
|
|||||||
"The key algorithm '%s' is not allowed to be used by"
|
"The key algorithm '%s' is not allowed to be used by"
|
||||||
" PUBLICKEY_ACCEPTED_TYPES configuration option",
|
" PUBLICKEY_ACCEPTED_TYPES configuration option",
|
||||||
sig_type_c);
|
sig_type_c);
|
||||||
ssh_string_free(str);
|
SSH_STRING_FREE(pubkey_s);
|
||||||
return SSH_AUTH_DENIED;
|
return SSH_AUTH_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,22 +742,21 @@ static int ssh_userauth_agent_publickey(ssh_session session,
|
|||||||
"publickey",
|
"publickey",
|
||||||
1, /* private key */
|
1, /* private key */
|
||||||
sig_type_c, /* algo */
|
sig_type_c, /* algo */
|
||||||
str /* public key */
|
pubkey_s /* public key */
|
||||||
);
|
);
|
||||||
ssh_string_free(str);
|
SSH_STRING_FREE(pubkey_s);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sign the buffer with the private key */
|
/* sign the buffer with the private key */
|
||||||
str = ssh_pki_do_sign_agent(session, session->out_buffer, pubkey);
|
sig_blob = ssh_pki_do_sign_agent(session, session->out_buffer, pubkey);
|
||||||
if (str == NULL) {
|
if (sig_blob == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_buffer_add_ssh_string(session->out_buffer, str);
|
rc = ssh_buffer_add_ssh_string(session->out_buffer, sig_blob);
|
||||||
ssh_string_free(str);
|
SSH_STRING_FREE(sig_blob);
|
||||||
str = NULL;
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -779,7 +779,7 @@ pending:
|
|||||||
fail:
|
fail:
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
ssh_buffer_reinit(session->out_buffer);
|
ssh_buffer_reinit(session->out_buffer);
|
||||||
ssh_string_free(str);
|
SSH_STRING_FREE(pubkey_s);
|
||||||
|
|
||||||
return SSH_AUTH_ERROR;
|
return SSH_AUTH_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user