1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
From 48b6ea32e21db8b580cd3ca8c346c3e2c22756f6 Mon Sep 17 00:00:00 2001
From: Kevin McCarthy <kevin@8t8.us>
Date: Mon, 31 Oct 2022 15:02:57 -0700
Subject: [PATCH] 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.
---
crypt-gpgme.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index e74caecba34e..5c3c0fe51669 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;
}
--
2.38.1
|