aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2015-05-19 01:14:09 +0000
committerNIIBE Yutaka <[email protected]>2015-05-19 01:25:22 +0000
commit76e2aa739c0c75a9de7059daebdf2823582d8b24 (patch)
tree8c7bbcafbd0de8081f7ce22e545df4622dfeb8cd
parentgpg-connect-agent: Fix quoting of internal percent+ function. (diff)
downloadgnupg-76e2aa739c0c75a9de7059daebdf2823582d8b24.tar.gz
gnupg-76e2aa739c0c75a9de7059daebdf2823582d8b24.zip
g10: Improve handling of no corresponding public key.
* g10/getkey.c (get_seckey): Return G10ERR_NO_PUBKEY when it's not exact match. -- (ported from 1.4 commit b3fd30451a5464b124b0296afbc341cb98b3977c) In the situation of corrupted .gnupg/ where only private subkey is available but no corresponding public key of the subkey, the code returned public primary key which caused mysterious error (for a user). This fix detects an error earlier. GnuPG-bug-id: 1422 Debian-Bug-Id: #638619
-rw-r--r--g10/getkey.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 8b3cf2d24..a27c8e28a 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -500,7 +500,19 @@ get_seckey( PKT_secret_key *sk, u32 *keyid )
ctx.req_usage = sk->req_usage;
rc = lookup( &ctx, &kb, 1 );
if ( !rc ) {
+ u32 skid[2];
+
sk_from_block ( &ctx, sk, kb );
+ keyid_from_sk ( sk, skid );
+ /*
+ * Make sure it's exact match of keyid.
+ * If not, it's secret subkey with no public key.
+ */
+ if (!(keyid[0] == skid[0] && keyid[1] == skid[1])) {
+ log_error (_("key %s: secret key without public key"
+ " - skipped\n"), keystr(keyid));
+ rc = G10ERR_NO_PUBKEY;
+ }
}
get_seckey_end( &ctx );
release_kbnode ( kb );