chiark / gitweb /
Import gnupg2_2.1.18-6.debian.tar.bz2
[gnupg2.git] / patches / 0028-scd-Backport-two-fixes-from-master.patch
1 From: NIIBE Yutaka <gniibe@fsij.org>
2 Date: Sun, 5 Feb 2017 08:34:08 +0900
3 Subject: scd: Backport two fixes from master.
4
5 * scd/app.c (app_new_register): Initialize by -1, so that it can detect
6 an error correctly when card reader can't power-on the card initially.
7 * scd/command.c (open_card_with_request): Release APP before the scan.
8
9 --
10 The first one-liner patch handles an erroneous card.
11
12 The second patch handles the case when we repeatedly do
13 signing/decrypting by a single session of scdaemon.
14
15 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
16 ---
17  scd/app.c     | 1 +
18  scd/command.c | 5 +++++
19  2 files changed, 6 insertions(+)
20
21 diff --git a/scd/app.c b/scd/app.c
22 index b10a452d6..989e0c060 100644
23 --- a/scd/app.c
24 +++ b/scd/app.c
25 @@ -192,6 +192,7 @@ app_new_register (int slot, ctrl_t ctrl, const char *name)
26      }
27  
28    app->slot = slot;
29 +  app->card_status = (unsigned int)-1;
30  
31    if (npth_mutex_init (&app->lock, NULL))
32      {
33 diff --git a/scd/command.c b/scd/command.c
34 index 8c7ca20a6..0ae6d29aa 100644
35 --- a/scd/command.c
36 +++ b/scd/command.c
37 @@ -217,6 +217,7 @@ open_card_with_request (ctrl_t ctrl, const char *apptype, const char *serialno)
38    gpg_error_t err;
39    unsigned char *serialno_bin = NULL;
40    size_t serialno_bin_len = 0;
41 +  app_t app = ctrl->app_ctx;
42  
43    /* If we are already initialized for one specific application we
44       need to check that the client didn't requested a specific
45 @@ -224,6 +225,10 @@ open_card_with_request (ctrl_t ctrl, const char *apptype, const char *serialno)
46    if (apptype && ctrl->app_ctx)
47      return check_application_conflict (apptype, ctrl->app_ctx);
48  
49 +  /* Re-scan USB devices.  Release APP, before the scan.  */
50 +  ctrl->app_ctx = NULL;
51 +  release_application (app);
52 +
53    if (serialno)
54      serialno_bin = hex_to_buffer (serialno, &serialno_bin_len);
55