mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
scd: Fix READER-PORT option handling for PC/SC.
* scd/apdu.c (apdu_open_reader): READERNO should be -1 when READER-PORT is specified for PC/SC. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
21ef425e22
commit
ee5b6af370
44
scd/apdu.c
44
scd/apdu.c
@ -2129,32 +2129,42 @@ apdu_open_reader (struct dev_list *dl)
|
|||||||
if (!dl->table)
|
if (!dl->table)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBUSB
|
||||||
/* See whether we want to use the reader ID string or a reader
|
/* See whether we want to use the reader ID string or a reader
|
||||||
number. A readerno of -1 indicates that the reader ID string is
|
number. A readerno of -1 indicates that the reader ID string is
|
||||||
to be used. */
|
to be used. */
|
||||||
if (dl->portstr && strchr (dl->portstr, ':'))
|
if (dl->portstr)
|
||||||
readerno = -1; /* We want to use the readerid. */
|
|
||||||
else if (dl->portstr)
|
|
||||||
{
|
{
|
||||||
readerno = atoi (dl->portstr);
|
if (!opt.disable_ccid || strchr (dl->portstr, ':'))
|
||||||
if (readerno < 0 || readerno >= dl->idx_max)
|
readerno = -1; /* We want to use the readerid. */
|
||||||
return -1;
|
else
|
||||||
|
{
|
||||||
npth_mutex_lock (&reader_table_lock);
|
readerno = atoi (dl->portstr);
|
||||||
/* If already opened HANDLE, return -1. */
|
if (readerno < 0 || readerno >= dl->idx_max)
|
||||||
for (slot = 0; slot < MAX_READER; slot++)
|
|
||||||
if (reader_table[slot].used)
|
|
||||||
{
|
|
||||||
npth_mutex_unlock (&reader_table_lock);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
npth_mutex_unlock (&reader_table_lock);
|
|
||||||
|
|
||||||
dl->idx = readerno;
|
npth_mutex_lock (&reader_table_lock);
|
||||||
dl->portstr = NULL;
|
/* If already opened HANDLE, return -1. */
|
||||||
|
for (slot = 0; slot < MAX_READER; slot++)
|
||||||
|
if (reader_table[slot].used)
|
||||||
|
{
|
||||||
|
npth_mutex_unlock (&reader_table_lock);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
npth_mutex_unlock (&reader_table_lock);
|
||||||
|
|
||||||
|
dl->idx = readerno;
|
||||||
|
dl->portstr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
readerno = 0; /* Default. */
|
readerno = 0; /* Default. */
|
||||||
|
#else
|
||||||
|
if (dl->portstr)
|
||||||
|
readerno = -1; /* We want to use the readerid. */
|
||||||
|
else
|
||||||
|
readerno = 0; /* Default. */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBUSB
|
#ifdef HAVE_LIBUSB
|
||||||
if (!opt.disable_ccid)
|
if (!opt.disable_ccid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user