chiark / gitweb /
scd: Backport two fixes from master.
authorNIIBE Yutaka <gniibe@fsij.org>
Sat, 4 Feb 2017 23:34:08 +0000 (08:34 +0900)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 18 Sep 2017 20:41:12 +0000 (21:41 +0100)
* 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 <gniibe@fsij.org>
Gbp-Pq: Name 0028-scd-Backport-two-fixes-from-master.patch

scd/app.c
scd/command.c

index b10a452d6c78a168272f2eb9dd3de0d30860cfce..989e0c06096cbfd4346559b0d38df85c3812244e 100644 (file)
--- 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))
     {
index 8c7ca20a637cda131acc09868433c807858e6785..0ae6d29aa83d076c7f876323092747be7f66415a 100644 (file)
@@ -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);