mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
scd:nks: Fix caching keygrip (more).
* scd/app-nks.c (keygripstr_from_pk_file): Distinguish by APP_ID.
--
GnuPG-bug-id: 5150, 5161
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Backported-from-master: 87d2c579cc
Fixes-commit: 00f594e3ecb26b010e87d5491b648369e7a92408
This commit is contained in:
parent
cf5f6896f8
commit
c9eb4c0632
1 changed files with 7 additions and 5 deletions
|
@ -176,6 +176,7 @@ static struct
|
||||||
/* Object to cache information gathered from FIDs. */
|
/* Object to cache information gathered from FIDs. */
|
||||||
struct fid_cache_s {
|
struct fid_cache_s {
|
||||||
struct fid_cache_s *next;
|
struct fid_cache_s *next;
|
||||||
|
int nks_app_id;
|
||||||
int fid; /* Zero for an unused slot. */
|
int fid; /* Zero for an unused slot. */
|
||||||
unsigned int got_keygrip:1; /* The keygrip and algo are valid. */
|
unsigned int got_keygrip:1; /* The keygrip and algo are valid. */
|
||||||
int algo;
|
int algo;
|
||||||
|
@ -294,8 +295,8 @@ keygripstr_from_pk_file (app_t app, int pkfid, int cfid, char *r_gripstr,
|
||||||
struct fid_cache_s *ci;
|
struct fid_cache_s *ci;
|
||||||
|
|
||||||
for (ci = app->app_local->fid_cache; ci; ci = ci->next)
|
for (ci = app->app_local->fid_cache; ci; ci = ci->next)
|
||||||
if (ci->fid && ((cfid > 0 && ci->fid == cfid)
|
if (ci->fid && ci->nks_app_id == app->app_local->active_nks_app
|
||||||
|| (!(cfid > 0) && ci->fid == pkfid)))
|
&& ci->fid == pkfid)
|
||||||
{
|
{
|
||||||
if (!ci->got_keygrip)
|
if (!ci->got_keygrip)
|
||||||
return gpg_error (GPG_ERR_NOT_FOUND);
|
return gpg_error (GPG_ERR_NOT_FOUND);
|
||||||
|
@ -465,8 +466,8 @@ keygripstr_from_pk_file (app_t app, int pkfid, int cfid, char *r_gripstr,
|
||||||
/* FIXME: We need to implement not_found caching. */
|
/* FIXME: We need to implement not_found caching. */
|
||||||
for (ci = app->app_local->fid_cache; ci; ci = ci->next)
|
for (ci = app->app_local->fid_cache; ci; ci = ci->next)
|
||||||
if (ci->fid
|
if (ci->fid
|
||||||
&& ((cfid > 0 && ci->fid == cfid)
|
&& ci->nks_app_id == app->app_local->active_nks_app
|
||||||
|| (!(cfid > 0) && ci->fid == pkfid)))
|
&& ci->fid == pkfid)
|
||||||
{
|
{
|
||||||
/* Update the keygrip. */
|
/* Update the keygrip. */
|
||||||
memcpy (ci->keygripstr, r_gripstr, 2*KEYGRIP_LEN+1);
|
memcpy (ci->keygripstr, r_gripstr, 2*KEYGRIP_LEN+1);
|
||||||
|
@ -487,7 +488,8 @@ keygripstr_from_pk_file (app_t app, int pkfid, int cfid, char *r_gripstr,
|
||||||
; /* Out of memory - it is a cache, so we ignore it. */
|
; /* Out of memory - it is a cache, so we ignore it. */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ci->fid = (cfid > 0)? cfid : pkfid;
|
ci->nks_app_id = app->app_local->active_nks_app;
|
||||||
|
ci->fid = pkfid;
|
||||||
memcpy (ci->keygripstr, r_gripstr, 2*KEYGRIP_LEN+1);
|
memcpy (ci->keygripstr, r_gripstr, 2*KEYGRIP_LEN+1);
|
||||||
ci->algo = algo;
|
ci->algo = algo;
|
||||||
ci->got_keygrip = 1;
|
ci->got_keygrip = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue