aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2021-05-13 01:35:08 +0000
committerNIIBE Yutaka <[email protected]>2021-05-13 01:35:08 +0000
commit3802703ef22920758864c080b7a2ea3c64dd7ca8 (patch)
tree615694773aa8f7afc3a3f8baefeda05d03ab7883
parentagent: Use SHA-256 for SSH fingerprint by default (diff)
downloadgnupg-3802703ef22920758864c080b7a2ea3c64dd7ca8.tar.gz
gnupg-3802703ef22920758864c080b7a2ea3c64dd7ca8.zip
scd: Protect PCSC.CONTEXT in apdu_dev_list_start.
* scd/apdu.c (apdu_dev_list_start): Make sure using valid PCSC.CONTEXT. -- Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--scd/apdu.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index ae6d8664b..a081b37f0 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -2018,12 +2018,14 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
pcsc_dword_t nreader;
char *p = NULL;
+ npth_mutex_lock (&reader_table_lock);
if (!pcsc.context)
{
/* log_debug ("%s: No context - calling init\n", __func__); */
if (pcsc_init () < 0)
{
xfree (dl);
+ npth_mutex_unlock (&reader_table_lock);
return gpg_error (GPG_ERR_NO_SERVICE);
}
}
@@ -2040,6 +2042,7 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
if (pcsc.count == 0)
release_pcsc_context ();
xfree (dl);
+ npth_mutex_unlock (&reader_table_lock);
return err;
}
r = pcsc_list_readers (pcsc.context, NULL, p, &nreader);
@@ -2052,9 +2055,12 @@ apdu_dev_list_start (const char *portstr, struct dev_list **l_p)
if (pcsc.count == 0)
release_pcsc_context ();
xfree (dl);
+ npth_mutex_unlock (&reader_table_lock);
return iso7816_map_sw (pcsc_error_to_sw (r));
}
+ npth_mutex_unlock (&reader_table_lock);
+
dl->table = p;
dl->idx_max = 0;