gpg: Fix selection of key.

* g10/getkey.c (pubkey_cmp): Handle the case of TRUST_EXPIRED.

--

GnuPG-bug-id: 4713
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2021-02-05 13:49:10 +09:00
parent 7f3ce66ec5
commit 390f597868
1 changed files with 3 additions and 1 deletions

View File

@ -1359,7 +1359,9 @@ pubkey_cmp (ctrl_t ctrl, const char *name, struct pubkey_cmp_cookie *old,
if (! uid_is_ok (&old->key, old->uid) && uid_is_ok (&new->key, uid))
return -1; /* Validity of the NEW key is better. */
if (old->validity < new->validity)
if (new->validity != TRUST_EXPIRED && old->validity < new->validity)
return -1; /* Validity of the NEW key is better. */
if (old->validity == TRUST_EXPIRED && new->validity != TRUST_EXPIRED)
return -1; /* Validity of the NEW key is better. */
if (old->validity == new->validity && uid_is_ok (&new->key, uid)