diff options
author | NIIBE Yutaka <[email protected]> | 2021-06-07 02:38:25 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2021-06-07 02:38:25 +0000 |
commit | ee5b6af370fbee1b08136e5dc384cf7996bcfc4c (patch) | |
tree | ec41384a5bbf7f55c29ae89d25fe49956bec56ad | |
parent | agent: Appropriate error code for importing key with no passwd. (diff) | |
download | gnupg-ee5b6af370fbee1b08136e5dc384cf7996bcfc4c.tar.gz gnupg-ee5b6af370fbee1b08136e5dc384cf7996bcfc4c.zip |
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 <[email protected]>
-rw-r--r-- | scd/apdu.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/scd/apdu.c b/scd/apdu.c index 62aefb8cf..ec495e374 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -2129,32 +2129,42 @@ apdu_open_reader (struct dev_list *dl) if (!dl->table) return -1; +#ifdef HAVE_LIBUSB /* 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 to be used. */ - if (dl->portstr && strchr (dl->portstr, ':')) - readerno = -1; /* We want to use the readerid. */ - else if (dl->portstr) + if (dl->portstr) { - readerno = atoi (dl->portstr); - if (readerno < 0 || readerno >= dl->idx_max) - return -1; - - npth_mutex_lock (&reader_table_lock); - /* If already opened HANDLE, return -1. */ - for (slot = 0; slot < MAX_READER; slot++) - if (reader_table[slot].used) - { - npth_mutex_unlock (&reader_table_lock); + if (!opt.disable_ccid || strchr (dl->portstr, ':')) + readerno = -1; /* We want to use the readerid. */ + else + { + readerno = atoi (dl->portstr); + if (readerno < 0 || readerno >= dl->idx_max) return -1; - } - npth_mutex_unlock (&reader_table_lock); - dl->idx = readerno; - dl->portstr = NULL; + npth_mutex_lock (&reader_table_lock); + /* 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 readerno = 0; /* Default. */ +#else + if (dl->portstr) + readerno = -1; /* We want to use the readerid. */ + else + readerno = 0; /* Default. */ +#endif #ifdef HAVE_LIBUSB if (!opt.disable_ccid) |