From f05a63b10428df2878b1bb6fde57a2fc2aa99105 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 4 Aug 2015 12:28:17 +0200 Subject: [PATCH] gpg: Properly handle legacy keys while looking for a secret key. * g10/getkey.c (have_secret_key_with_kid): Skip legacy keys. -- This fixes GnuPG-bug-id: 2031 Signed-off-by: Werner Koch --- g10/getkey.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/g10/getkey.c b/g10/getkey.c index f02e8c2b1..3a6016113 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -3058,8 +3058,14 @@ have_secret_key_with_kid (u32 *keyid) desc.mode = KEYDB_SEARCH_MODE_LONG_KID; desc.u.kid[0] = keyid[0]; desc.u.kid[1] = keyid[1]; - while (!result && !(err = keydb_search (kdbhd, &desc, 1, NULL))) + while (!result) { + err = keydb_search (kdbhd, &desc, 1, NULL); + if (gpg_err_code (err) == GPG_ERR_LEGACY_KEY) + continue; + if (err) + break; + err = keydb_get_keyblock (kdbhd, &keyblock); if (err) { @@ -3085,6 +3091,7 @@ have_secret_key_with_kid (u32 *keyid) } release_kbnode (keyblock); } + keydb_release (kdbhd); return result; }