From: NIIBE Yutaka Date: Sat, 4 Feb 2017 23:34:08 +0000 (+0900) Subject: scd: Backport two fixes from master. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=450157c487d230a1dc571e6fe59422ac15ffbd9c;p=gnupg2.git scd: Backport two fixes from master. * scd/app.c (app_new_register): Initialize by -1, so that it can detect an error correctly when card reader can't power-on the card initially. * scd/command.c (open_card_with_request): Release APP before the scan. -- The first one-liner patch handles an erroneous card. The second patch handles the case when we repeatedly do signing/decrypting by a single session of scdaemon. Signed-off-by: NIIBE Yutaka Gbp-Pq: Name 0028-scd-Backport-two-fixes-from-master.patch --- diff --git a/scd/app.c b/scd/app.c index b10a452..989e0c0 100644 --- a/scd/app.c +++ b/scd/app.c @@ -192,6 +192,7 @@ app_new_register (int slot, ctrl_t ctrl, const char *name) } app->slot = slot; + app->card_status = (unsigned int)-1; if (npth_mutex_init (&app->lock, NULL)) { diff --git a/scd/command.c b/scd/command.c index 8c7ca20..0ae6d29 100644 --- a/scd/command.c +++ b/scd/command.c @@ -217,6 +217,7 @@ open_card_with_request (ctrl_t ctrl, const char *apptype, const char *serialno) gpg_error_t err; unsigned char *serialno_bin = NULL; size_t serialno_bin_len = 0; + app_t app = ctrl->app_ctx; /* If we are already initialized for one specific application we need to check that the client didn't requested a specific @@ -224,6 +225,10 @@ open_card_with_request (ctrl_t ctrl, const char *apptype, const char *serialno) if (apptype && ctrl->app_ctx) return check_application_conflict (apptype, ctrl->app_ctx); + /* Re-scan USB devices. Release APP, before the scan. */ + ctrl->app_ctx = NULL; + release_application (app); + if (serialno) serialno_bin = hex_to_buffer (serialno, &serialno_bin_len);