mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
310b064f52
commit
3802703ef2
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user