diff options
author | NIIBE Yutaka <[email protected]> | 2020-12-03 07:21:49 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2020-12-03 07:21:49 +0000 |
commit | 87d2c579cc38c1d2787945650125fb0e0336652c (patch) | |
tree | 70a17e1136b40c090fcdd1712d4344c6bfd6d7db /scd/app-nks.c | |
parent | scd: Fix KEYINFO command with --data option. (diff) | |
download | gnupg-87d2c579cc38c1d2787945650125fb0e0336652c.tar.gz gnupg-87d2c579cc38c1d2787945650125fb0e0336652c.zip |
scd:nks: Fix caching keygrip (more).
* scd/app-nks.c (keygripstr_from_pk_file): Distinguish by APP_ID.
--
GnuPG-bug-id: 5150, 5161
Fixes-commit: 920154370834ad8d947aed19c9d914a27dde6baa
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd/app-nks.c')
-rw-r--r-- | scd/app-nks.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/scd/app-nks.c b/scd/app-nks.c index 348b0c1dc..af0a4d545 100644 --- a/scd/app-nks.c +++ b/scd/app-nks.c @@ -176,6 +176,7 @@ static struct /* Object to cache information gathered from FIDs. */ struct fid_cache_s { struct fid_cache_s *next; + int nks_app_id; int fid; /* Zero for an unused slot. */ unsigned int got_keygrip:1; /* The keygrip and algo are valid. */ 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; for (ci = app->app_local->fid_cache; ci; ci = ci->next) - if (ci->fid && ((cfid > 0 && ci->fid == cfid) - || (!(cfid > 0) && ci->fid == pkfid))) + if (ci->fid && ci->nks_app_id == app->app_local->active_nks_app + && ci->fid == pkfid) { if (!ci->got_keygrip) 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. */ for (ci = app->app_local->fid_cache; ci; ci = ci->next) if (ci->fid - && ((cfid > 0 && ci->fid == cfid) - || (!(cfid > 0) && ci->fid == pkfid))) + && ci->nks_app_id == app->app_local->active_nks_app + && ci->fid == pkfid) { /* Update the keygrip. */ 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. */ 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); ci->algo = algo; ci->got_keygrip = 1; |