On Thu, Apr 18, 2019 at 04:51:07PM +0100, Julian Gilbey wrote:
> On Sun, Apr 08, 2018 at 03:56:19PM +0100, Julian Gilbey wrote:
> Hello!
> 
> I've located and fixed the source of this bug; a patch is attached.
> I've also submitted it upstream as
> https://gitlab.com/muttmua/mutt/merge_requests/43
> 
> Best wishes,
> 
>    Julian

It turns out my patch wasn't quite correct, but the fixed patch has
now been applied upstream; I attach it here, but when a new version of
mutt is packaged (dated later than today), this Debian bug can be
closed.

Best wishes,

   Julian
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index 3a1ed8a5..696daa62 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -940,6 +940,7 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime)
   gpgme_error_t err;
   gpgme_ctx_t listctx;
   gpgme_key_t key, key2;
+  char *fpr, *fpr2;
 
   if (for_smime)
     signid = (SmimeSignAs && *SmimeSignAs) ? SmimeSignAs : SmimeDefaultKey;
@@ -960,15 +961,25 @@ static int set_signer (gpgme_ctx_t ctx, int for_smime)
                   signid, gpgme_strerror (err));
       return -1;
     }
-  err = gpgme_op_keylist_next (listctx, &key2);
-  if (!err)
+  fpr = "fpr1";
+  if (key->subkeys)
+    fpr = key->subkeys->fpr ? key->subkeys->fpr : key->subkeys->keyid;
+  while (! gpgme_op_keylist_next (listctx, &key2))
     {
-      gpgme_key_unref (key);
-      gpgme_key_unref (key2);
-      gpgme_release (listctx);
-      mutt_error (_("ambiguous specification of secret key `%s'\n"),
-                  signid);
-      return -1;
+      fpr2 = "fpr2";
+      if (key2->subkeys)
+        fpr2 = key2->subkeys->fpr ? key2->subkeys->fpr : key2->subkeys->keyid;
+      if (mutt_strcmp(fpr, fpr2))
+        {
+          gpgme_key_unref (key);
+          gpgme_key_unref (key2);
+          gpgme_release (listctx);
+          mutt_error (_("ambiguous specification of secret key `%s'\n"),
+                      signid);
+          return -1;
+        } else {
+          gpgme_key_unref (key2);
+        }
     }
   gpgme_op_keylist_end (listctx);
   gpgme_release (listctx);

Reply via email to