]> granicus.if.org Git - mutt/commitdiff
Add an error message in case keys can be found, but none are valid.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 3 Apr 2001 17:25:58 +0000 (17:25 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 3 Apr 2001 17:25:58 +0000 (17:25 +0000)
pgpkey.c

index 838ed7b8578996e80608c197fac35b89074956d6..648e50ff4d073d93c03c777525a96d770bcc89f6 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -434,18 +434,26 @@ static pgp_key_t *pgp_select_key (pgp_key_t *keys,
   pgp_uid_t *a;
   int (*f) (const void *, const void *);
 
-  keymax = 5;
-  KeyTable = safe_malloc (sizeof (pgp_key_t *) * keymax);
+  int unsuable = 0;
+
+  keymax = 0;
+  KeyTable = NULL;
 
   for (i = 0, kp = keys; kp; kp = kp->next)
   {
     if (!option (OPTPGPSHOWUNUSABLE) && (kp->flags & KEYFLAG_CANTUSE))
+    {
+      unusable = 1;
       continue;
-       
+    }
+
     for (a = kp->address; a; a = a->next)
     {
       if (!option (OPTPGPSHOWUNUSABLE) && (a->flags & KEYFLAG_CANTUSE))
+      {
+       unusable = 1;
        continue;
+      }
       
       if (i == keymax)
       {
@@ -457,6 +465,12 @@ static pgp_key_t *pgp_select_key (pgp_key_t *keys,
     }
   }
 
+  if (!i && unusable)
+  {
+    mutt_error _("All matching keys are marked expired/revoked.");
+    return NULL;
+  }
+
   switch (PgpSortKeys & SORT_MASK)
   {
     case SORT_DATE: