1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-31 22:18:03 +02:00

scd: Take the card look while running app->with_keygrip.

* scd/app.c (app_do_with_keygrip): Lock the card.
--

Better safe than sorry.

We should also review the card reference counting to see whether we
better ref the returned card object already here.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-06-21 14:51:55 +02:00
parent 0400a4eb17
commit b304c006a3
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -1492,6 +1492,7 @@ app_send_card_list (ctrl_t ctrl)
card_t card_t
app_do_with_keygrip (ctrl_t ctrl, int action, const char *keygrip_str) app_do_with_keygrip (ctrl_t ctrl, int action, const char *keygrip_str)
{ {
gpg_error_t err;
card_t c; card_t c;
app_t a; app_t a;
@ -1499,9 +1500,17 @@ app_do_with_keygrip (ctrl_t ctrl, int action, const char *keygrip_str)
for (c = card_top; c; c = c->next) for (c = card_top; c; c = c->next)
for (a = c->app; a; a = a->next) for (a = c->app; a; a = a->next)
if (a->fnc.with_keygrip if (a->fnc.with_keygrip)
&& !a->fnc.with_keygrip (a, ctrl, action, keygrip_str)) {
break; if (!lock_card (c, ctrl))
{
err = a->fnc.with_keygrip (a, ctrl, action, keygrip_str);
unlock_card (c);
if (!err)
break;
}
}
/* FIXME: Add app switching logic. The above code assumes that the /* FIXME: Add app switching logic. The above code assumes that the
* actions can be performend without switching. This needs to be * actions can be performend without switching. This needs to be
* checked. For a lookup we also need to reorder the apps so that * checked. For a lookup we also need to reorder the apps so that