From 4a326d7c9a3b09efcccf4de00d6c003829ad89e8 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 4 Aug 2015 17:32:08 +0200 Subject: [PATCH] gpg: Fix duplicate key import due to legacy key in keyring. * g10/keydb.c (keydb_search_fpr): Skip legacy keys. -- A test case for this problem can be found at GnuPG-bug-id: 2031 Signed-off-by: Werner Koch --- g10/keydb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/g10/keydb.c b/g10/keydb.c index 68cf8328d..3dc9ec72e 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -1753,10 +1753,17 @@ keydb_search_kid (KEYDB_HANDLE hd, u32 *kid) gpg_error_t keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr) { + gpg_error_t err; KEYDB_SEARCH_DESC desc; memset (&desc, 0, sizeof desc); desc.mode = KEYDB_SEARCH_MODE_FPR; memcpy (desc.u.fpr, fpr, MAX_FINGERPRINT_LEN); - return keydb_search (hd, &desc, 1, NULL); + do + { + err = keydb_search (hd, &desc, 1, NULL); + } + while (gpg_err_code (err) == GPG_ERR_LEGACY_KEY); + + return err; }