diff options
author | Neal H. Walfield <[email protected]> | 2015-09-16 11:13:46 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2015-09-16 13:15:26 +0000 |
commit | 5e233e12f55be00f5659c63bc32fbdca2ec93136 (patch) | |
tree | 686f817104f7895fa74cfa5a722353d03a5b31c0 /g10/getkey.c | |
parent | g10: Break out of the loop earlier. (diff) | |
download | gnupg-5e233e12f55be00f5659c63bc32fbdca2ec93136.tar.gz gnupg-5e233e12f55be00f5659c63bc32fbdca2ec93136.zip |
g10: Bring cache semantics closer to non-cache semantics.
* g10/getkey.c (get_pubkey_fast): When reading from the cache, only
consider primary keys.
--
Signed-off-by: Neal H. Walfield <[email protected]>.
Diffstat (limited to 'g10/getkey.c')
-rw-r--r-- | g10/getkey.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/g10/getkey.c b/g10/getkey.c index 20c344dfa..f41c2c91c 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -437,7 +437,10 @@ get_pubkey_fast (PKT_public_key * pk, u32 * keyid) for (ce = pk_cache; ce; ce = ce->next) { - if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]) + if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] + /* Only consider primary keys. */ + && ce->pk->keyid[0] == ce->pk->main_keyid[0] + && ce->pk->keyid[1] == ce->pk->main_keyid[1]) { if (pk) copy_public_key (pk, ce->pk); @@ -463,9 +466,10 @@ get_pubkey_fast (PKT_public_key * pk, u32 * keyid) } assert (keyblock && keyblock->pkt - && (keyblock->pkt->pkttype == PKT_PUBLIC_KEY - || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY)); + && keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + /* We return the primary key. If KEYID matched a subkey, then we + return an error. */ keyid_from_pk (keyblock->pkt->pkt.public_key, pkid); if (keyid[0] == pkid[0] && keyid[1] == pkid[1]) copy_public_key (pk, keyblock->pkt->pkt.public_key); |