From b5075030bec9b21bf4e515bc1686df3fa43eced2 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 1 Feb 2017 18:03:35 +0100 Subject: [PATCH] core: Fix leakage of address for mail only uids * src/key.c (gpgme_key_unref): Always free address if set. (_gpgme_key_append_name): Remove memory optimization for address. -- The check if address is not allocated would now be more complicated then just comparing it to email because email is set to address also when an email was not parsed from the user id. --- src/key.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/key.c b/src/key.c index fed020e7..e33abd0f 100644 --- a/src/key.c +++ b/src/key.c @@ -236,12 +236,6 @@ _gpgme_key_append_name (gpgme_key_t key, const char *src, int convert) &uid->comment, dst); uid->address = _gpgme_mailbox_from_userid (uid->uid); - if (uid->address && uid->email && !strcmp (uid->address, uid->email)) - { - /* The ADDRESS is the same as EMAIL: Save some space. */ - free (uid->address); - uid->address = uid->email; - } if ((!uid->email || !*uid->email) && uid->address && uid->name && !strcmp (uid->name, uid->address)) { @@ -394,9 +388,7 @@ gpgme_key_unref (gpgme_key_t key) tofu = tofu_next; } - if (uid->address && uid->address != uid->email) - free (uid->address); - + free (uid->address); free (uid); uid = next_uid; }