summaryrefslogtreecommitdiffstats
path: root/tools/wks-util.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-08-20 16:15:49 +0200
committerWerner Koch <wk@gnupg.org>2021-08-20 16:15:49 +0200
commit87d238de3d9d537cacc9dd3c6d954845203ea2cb (patch)
tree114bf30461c6c196d3c28d94de461669e4d3845d /tools/wks-util.c
parentwkd: Fix client issue with leading or trailing spaces in user-ids. (diff)
downloadgnupg2-87d238de3d9d537cacc9dd3c6d954845203ea2cb.tar.xz
gnupg2-87d238de3d9d537cacc9dd3c6d954845203ea2cb.zip
wkd: Properly unescape the user-id from a key listing.
* tools/wks-util.c (append_to_uidinfo_list): Unescape UID.
Diffstat (limited to '')
-rw-r--r--tools/wks-util.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/wks-util.c b/tools/wks-util.c
index b9512ba1b..cf07a0cb3 100644
--- a/tools/wks-util.c
+++ b/tools/wks-util.c
@@ -98,19 +98,28 @@ wks_write_status (int no, const char *format, ...)
/* Append UID to LIST and return the new item. On success LIST is
- * updated. On error ERRNO is set and NULL returned. */
+ * updated. C-style escaping is removed from UID. On error ERRNO is
+ * set and NULL returned. */
static uidinfo_list_t
append_to_uidinfo_list (uidinfo_list_t *list, const char *uid, time_t created)
{
uidinfo_list_t r, sl;
+ char *plainuid;
- sl = xtrymalloc (sizeof *sl + strlen (uid));
- if (!sl)
+ plainuid = decode_c_string (uid);
+ if (!plainuid)
return NULL;
- strcpy (sl->uid, uid);
+ sl = xtrymalloc (sizeof *sl + strlen (plainuid));
+ if (!sl)
+ {
+ xfree (plainuid);
+ return NULL;
+ }
+
+ strcpy (sl->uid, plainuid);
sl->created = created;
- sl->mbox = mailbox_from_userid (uid, 0);
+ sl->mbox = mailbox_from_userid (plainuid, 0);
sl->next = NULL;
if (!*list)
*list = sl;
@@ -120,6 +129,8 @@ append_to_uidinfo_list (uidinfo_list_t *list, const char *uid, time_t created)
;
r->next = sl;
}
+
+ xfree (plainuid);
return sl;
}
@@ -395,7 +406,6 @@ wks_list_key (estream_t key, char **r_fpr, uidinfo_list_t *r_mboxes)
}
else if (!strcmp (fields[0], "uid") && nfields > 9)
{
- /* Fixme: Unescape fields[9] */
if (!append_to_uidinfo_list (&mboxes, fields[9],
parse_timestamp (fields[5], NULL)))
{