summaryrefslogtreecommitdiffstats
path: root/scd/command.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2021-07-21 08:34:34 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2021-07-21 08:59:03 +0200
commitb436fb6766b400167e5d57ff1116600bb496b04f (patch)
treea63c34cbf96a4a9fd3078183b8d25545205a9da7 /scd/command.c
parentscd: Fix access to list of cards (1/3). (diff)
downloadgnupg2-b436fb6766b400167e5d57ff1116600bb496b04f.tar.xz
gnupg2-b436fb6766b400167e5d57ff1116600bb496b04f.zip
scd: Fix access to list of cards (2/3).
* scd/app-common.h (card_reset, select_application): Simplify. * scd/app.c (card_reset, select_application): Simplify. * scd/command.c (do_reset): Follow the change. (open_card, open_card_with_request): Follow the change. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd/command.c')
-rw-r--r--scd/command.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/scd/command.c b/scd/command.c
index cb0dd379a..d45d9da82 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -157,7 +157,16 @@ do_reset (ctrl_t ctrl, int send_reset, int keep_lock)
card_t card = ctrl->card_ctx;
if (card)
- card_reset (card, ctrl, IS_LOCKED (ctrl)? 0: send_reset);
+ {
+ if (!IS_LOCKED (ctrl) && send_reset)
+ card_reset (card, ctrl);
+ else
+ {
+ ctrl->card_ctx = NULL;
+ ctrl->current_apptype = APPTYPE_NONE;
+ card_unref (card);
+ }
+ }
/* If we hold a lock, unlock now. */
if (!keep_lock && locked_session && ctrl->server_local == locked_session)
@@ -223,7 +232,7 @@ open_card (ctrl_t ctrl)
if (ctrl->card_ctx)
return 0;
- return select_application (ctrl, NULL, &ctrl->card_ctx, 0, NULL, 0);
+ return select_application (ctrl, NULL, 0, NULL, 0);
}
/* Explicitly open a card for a specific use of APPTYPE or SERIALNO.
@@ -262,7 +271,7 @@ open_card_with_request (ctrl_t ctrl,
ctrl->current_apptype = APPTYPE_NONE;
card_unref (card);
- err = select_application (ctrl, apptypestr, &ctrl->card_ctx, 1,
+ err = select_application (ctrl, apptypestr, 1,
serialno_bin, serialno_bin_len);
if (!err && opt_all)
err = select_additional_application (ctrl, NULL);