mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
g10: Improve handling of no corresponding public key.
* g10/getkey.c (get_seckey): Return G10ERR_NO_PUBKEY when it's not exact match. -- 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
This commit is contained in:
parent
04667cabef
commit
b3fd30451a
12
g10/getkey.c
12
g10/getkey.c
@ -498,7 +498,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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user