1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-21 10:09:57 +01:00

agent: Avoid memory leak when handling ssh keys.

* agent/command-ssh.c (ssh_send_available_keys): Close file and
directory on error paths.

--

GnuPG-bug-id: 7201
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Jakub Jelen 2024-07-15 21:00:39 +02:00 committed by NIIBE Yutaka
parent be40a33419
commit dd23441938
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054

View File

@ -2602,6 +2602,7 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *r_key_counter)
if (!dirname)
{
err = gpg_error_from_syserror ();
ssh_close_control_file (cf);
agent_card_free_keyinfo (keyinfo_on_cards);
return err;
}
@ -2610,6 +2611,7 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *r_key_counter)
{
err = gpg_error_from_syserror ();
xfree (dirname);
ssh_close_control_file (cf);
agent_card_free_keyinfo (keyinfo_on_cards);
return err;
}
@ -2714,6 +2716,8 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *r_key_counter)
err = add_to_key_array (&keyarray, key_public, cardsn, order);
if (err)
{
gnupg_closedir (dir);
ssh_close_control_file (cf);
gcry_sexp_release (key_public);
xfree (cardsn);
goto leave;