1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

agent: Avoid memory leaks in error code paths.

* agent/command.c (cmd_genkey): Use goto instead of return.
* agent/cvt-openpgp.c (convert_from_openpgp_main): Ditto.
* agent/genkey.c (agent_ask_new_passphrase): Fix typo to free correct
pointer
(agent_genkey): Release memory
* agent/gpg-agent.c (check_own_socket): Free sockname
* agent/protect-tool.c (read_key): Free buf.
(agent_askpin): Free passphrase

--

Signed-off-by: Jakub Jelen <jjelen@redhat.com>

Changed original patch to not add a free before a GPG_ERR_BUG.

Signed-off-by: Werner Koch <wk@gnupg.org>
GnuPG-bug-id: 5393
This commit is contained in:
Jakub Jelen 2021-05-20 10:13:51 +02:00 committed by Werner Koch
parent a660e10606
commit a95ddffdcd
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
6 changed files with 23 additions and 8 deletions

View file

@ -363,7 +363,7 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
if (!pi2)
{
err = gpg_error_from_syserror ();
xfree (pi2);
xfree (pi);
return err;
}
pi->max_length = MAX_PASSPHRASE_LEN + 1;
@ -465,7 +465,10 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce, time_t timestamp,
"protect your new key"),
&passphrase_buffer);
if (rc)
return rc;
{
gcry_sexp_release (s_keyparam);
return rc;
}
passphrase = passphrase_buffer;
}