summaryrefslogtreecommitdiffstats
path: root/gnupgparse.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2014-08-12 14:33:17 -0700
committerKevin McCarthy <kevin@8t8.us>2014-08-12 14:33:17 -0700
commit835a3b1e7ffaca3aabd6fab9b72455be4319cbc4 (patch)
tree2c378e51b56f7d702edaa57ff68c5049305d0110 /gnupgparse.c
parent156784cc2fda068885f55f5d2e37227a5f3c50eb (diff)
Fix parse_pub_line to allow an empty User-ID field for a pub record. (see #3564)
A key whose primary uid record has an empty User-ID will result in the user being unable to use the key to encrypt an email in mutt. This is because the mutt functions for key selection iterate through the address fields of a key for matching against and for displaying to the user. This change allows a pgp_uid_t record to be created for a pub record whose User-ID field is blank. So the key will have one address record, albeit with a null addr field.
Diffstat (limited to 'gnupgparse.c')
-rw-r--r--gnupgparse.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gnupgparse.c b/gnupgparse.c
index 9de18ebd..9abd0360 100644
--- a/gnupgparse.c
+++ b/gnupgparse.c
@@ -120,6 +120,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
{
pgp_uid_t *uid = NULL;
int field = 0, is_uid = 0;
+ int is_pub = 0;
char *pend, *p;
int trust = 0;
int flags = 0;
@@ -144,7 +145,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
if ((pend = strchr (p, ':')))
*pend++ = 0;
field++;
- if (field > 1 && !*p)
+ if (!*p && (field != 1) && (field != 10))
continue;
switch (field)
@@ -154,7 +155,7 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
dprint (2, (debugfile, "record type: %s\n", p));
if (!mutt_strcmp (p, "pub"))
- ;
+ is_pub = 1;
else if (!mutt_strcmp (p, "sub"))
*is_subkey = 1;
else if (!mutt_strcmp (p, "sec"))
@@ -280,8 +281,14 @@ static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
break;
case 10: /* name */
{
- if (!pend || !*p)
- break; /* empty field or no trailing colon */
+ /* Empty field or no trailing colon.
+ * We allow an empty field for a pub record type because it is
+ * possible for a primary uid record to have an empty User-ID
+ * field. Without any address records, it is not possible to
+ * use the key in mutt.
+ */
+ if (!(pend && (*p || is_pub)))
+ break;
/* ignore user IDs on subkeys */
if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB)))