From 8e2a476fb7939e0086e3c711070100eab27c02b0 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Tue, 27 Jan 2004 17:36:26 +0000 Subject: [PATCH] * getkey.c: Set MAX_PK_CACHE_ENTRIES and MAX_UID_CACHE_ENTRIES to PK_UID_CACHE_SIZE (set in ./configure). * getkey.c (get_pubkey): When reading key data into the cache, properly handle keys that are partially (pk, no UIDs) cached already. This is Debian bug #176425 and #229549. --- g10/ChangeLog | 9 +++++++++ g10/getkey.c | 26 +++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 809031932..7bf2011aa 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,12 @@ +2004-01-27 David Shaw + + * getkey.c: Set MAX_PK_CACHE_ENTRIES and MAX_UID_CACHE_ENTRIES to + PK_UID_CACHE_SIZE (set in ./configure). + + * getkey.c (get_pubkey): When reading key data into the cache, + properly handle keys that are partially (pk, no UIDs) cached + already. This is Debian bug #176425 and #229549. + 2004-01-26 David Shaw * compress.c (init_compress): Remove "-z10" trick to get diff --git a/g10/getkey.c b/g10/getkey.c index 9b5bc8d55..7c4897964 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -35,14 +35,13 @@ #include "trustdb.h" #include "i18n.h" -#define MAX_PK_CACHE_ENTRIES 200 -#define MAX_UID_CACHE_ENTRIES 200 +#define MAX_PK_CACHE_ENTRIES PK_UID_CACHE_SIZE +#define MAX_UID_CACHE_ENTRIES PK_UID_CACHE_SIZE #if MAX_PK_CACHE_ENTRIES < 2 #error We need the cache for key creation #endif - struct getkey_ctx_s { int exact; KBNODE keyblock; @@ -320,16 +319,21 @@ get_pubkey( PKT_public_key *pk, u32 *keyid ) int rc = 0; #if MAX_PK_CACHE_ENTRIES - { /* Try to get it from the cache */ + if(pk) + { + /* Try to get it from the cache. We don't do this when pk is + NULL as it does not guarantee that the user IDs are + cached. */ pk_cache_entry_t ce; - for( ce = pk_cache; ce; ce = ce->next ) { - if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] ) { - if( pk ) - copy_public_key( pk, ce->pk ); + for( ce = pk_cache; ce; ce = ce->next ) + { + if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] ) + { + copy_public_key( pk, ce->pk ); return 0; - } - } - } + } + } + } #endif /* more init stuff */ if( !pk ) {