summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2022-10-31 15:02:57 -0700
committerKevin McCarthy <kevin@8t8.us>2022-11-01 19:40:22 -0700
commit48b6ea32e21db8b580cd3ca8c346c3e2c22756f6 (patch)
tree6b3ec915d671bcb9dfb299f5c0f7921e74191ac9
parent25b695304b1e74a7e2d221ca2f7dfec0afca5bf2 (diff)
Fix gpgme crash when listing keys in a public key block.
The gpgme code handling classic application/pgp assumed each key would have a uid. Change it to check for a missing uid list. Also change it to list every uid (instead of only the first), and to put each one on a "uid" line in the output. The output is only for display, so the format change won't affect other parts of the code. Thanks to Mikko Lehto for the high quality bug report, detailing the exact place of the crash with a reproducing example and a workaround patch.
-rw-r--r--crypt-gpgme.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index e74caecb..5c3c0fe5 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -2422,14 +2422,18 @@ static int pgp_gpgme_extract_keys (gpgme_data_t keydata, FILE** fp)
tt = subkey->timestamp;
strftime (date, sizeof (date), "%Y-%m-%d", localtime (&tt));
+ fprintf (*fp, "%s %5.5s %d/%8s %s\n",
+ more ? "sub" : "pub",
+ gpgme_pubkey_algo_name (subkey->pubkey_algo), subkey->length,
+ shortid, date);
if (!more)
- fprintf (*fp, "%s %5.5s %d/%8s %s %s\n", more ? "sub" : "pub",
- gpgme_pubkey_algo_name (subkey->pubkey_algo), subkey->length,
- shortid, date, uid->uid);
- else
- fprintf (*fp, "%s %5.5s %d/%8s %s\n", more ? "sub" : "pub",
- gpgme_pubkey_algo_name (subkey->pubkey_algo), subkey->length,
- shortid, date);
+ {
+ while (uid)
+ {
+ fprintf (*fp, "uid %s\n", NONULL (uid->uid));
+ uid = uid->next;
+ }
+ }
subkey = subkey->next;
more = 1;
}