summaryrefslogtreecommitdiffstats
path: root/g10/keyedit.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2021-05-20 10:13:51 +0200
committerWerner Koch <wk@gnupg.org>2021-05-20 13:38:39 +0200
commit2af7bb2295cda5377546cedd0c906a3cff4d2427 (patch)
tree3e912bccb258941b085959201b6c81b8940339a5 /g10/keyedit.c
parentdirmgr: clean up memory on error code paths (diff)
downloadgnupg2-2af7bb2295cda5377546cedd0c906a3cff4d2427.tar.xz
gnupg2-2af7bb2295cda5377546cedd0c906a3cff4d2427.zip
g10: Fix memory leaks
* g10/card-util.c (change_pin): free answer on errors (ask_card_keyattr): free answer on error * g10/cpr.c (do_get_from_fd): free string * g10/gpg.c (check_permissions): free dir on weird error * g10/import.c (append_new_uid): release knode * g10/keyedit.c (menu_set_keyserver_url): free answer (menu_set_keyserver_url): free user * g10/keygen.c (print_status_key_not_created): move allocation after sanity check (ask_expire_interval): free answer (card_store_key_with_backup): goto leave instaed of return * g10/keyserver.c (parse_keyserver_uri): goto fail instead of return * g10/revoke.c (gen_desig_revoke): release kdbhd (gen_desig_revoke): free answer * g10/tofu.c (ask_about_binding): free sqerr and response * g10/trustdb.c (ask_ownertrust): free pk -- Signed-off-by: Jakub Jelen <jjelen@redhat.com> Further changes: * g10/card-util.c (change_pin): Do not set answer to NULL. * g10/keyedit.c(menu_set_keyserver_url): Use !func() pattern. Signed-off-by: Werner Koch <wk@gnupg.org> GnuPG-bug-id: 5393
Diffstat (limited to 'g10/keyedit.c')
-rw-r--r--g10/keyedit.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 531d3e128..7255676e7 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -5306,8 +5306,11 @@ menu_set_keyserver_url (ctrl_t ctrl, const char *url, kbnode_t pub_keyblock)
}
}
- if (ascii_strcasecmp (answer, "none") == 0)
- uri = NULL;
+ if (!ascii_strcasecmp (answer, "none"))
+ {
+ xfree (answer);
+ uri = NULL;
+ }
else
{
struct keyserver_spec *keyserver = NULL;
@@ -5379,12 +5382,14 @@ menu_set_keyserver_url (ctrl_t ctrl, const char *url, kbnode_t pub_keyblock)
uri
? _("Are you sure you want to replace it? (y/N) ")
: _("Are you sure you want to delete it? (y/N) ")))
+ xfree (user);
continue;
}
else if (uri == NULL)
{
/* There is no current keyserver URL, so there
is no point in trying to un-set it. */
+ xfree (user);
continue;
}
@@ -5397,6 +5402,7 @@ menu_set_keyserver_url (ctrl_t ctrl, const char *url, kbnode_t pub_keyblock)
log_error ("update_keysig_packet failed: %s\n",
gpg_strerror (rc));
xfree (uri);
+ xfree (user);
return 0;
}
/* replace the packet */