aboutsummaryrefslogtreecommitdiffstats
path: root/agent/protect-tool.c
diff options
context:
space:
mode:
authorJakub Jelen <[email protected]>2021-05-20 08:13:51 +0000
committerWerner Koch <[email protected]>2021-05-20 11:38:07 +0000
commita95ddffdcd58383cce93677be5e7e11c5c229a98 (patch)
tree3705ec520ecc77efa85f07a85c66b47e9b162dca /agent/protect-tool.c
parentdirmngr: For KS_SEARCH return the fingerprint also with LDAP. (diff)
downloadgnupg-a95ddffdcd58383cce93677be5e7e11c5c229a98.tar.gz
gnupg-a95ddffdcd58383cce93677be5e7e11c5c229a98.zip
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 <[email protected]> Changed original patch to not add a free before a GPG_ERR_BUG. Signed-off-by: Werner Koch <[email protected]> GnuPG-bug-id: 5393
Diffstat (limited to 'agent/protect-tool.c')
-rw-r--r--agent/protect-tool.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index 1fcbd119f..bb17033a8 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -319,6 +319,7 @@ read_key (const char *fname)
if (buflen >= 4 && !memcmp (buf, "Key:", 4))
{
log_error ("Extended key format is not supported by this tool\n");
+ xfree (buf);
return NULL;
}
key = make_canonical (fname, buf, buflen);
@@ -793,7 +794,10 @@ agent_askpin (ctrl_t ctrl,
passphrase = get_passphrase (0);
size = strlen (passphrase);
if (size >= pininfo->max_length)
- return gpg_error (GPG_ERR_TOO_LARGE);
+ {
+ xfree (passphrase);
+ return gpg_error (GPG_ERR_TOO_LARGE);
+ }
memcpy (&pininfo->pin, passphrase, size);
xfree (passphrase);