1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd,pcsc: Fix error handling for a reader with reader-port.

* scd/apdu.c (apdu_open_reader): Make sure dl->idx is always
incremented to handle error from open_pcsc_reader correctly.

--

Reported-by: Anže Jenšterle
GnuPG-bug-id: 5758
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2022-01-04 14:56:29 +09:00
parent 4d52ba9431
commit f9c9938b28

View File

@ -2248,7 +2248,7 @@ apdu_open_reader (struct dev_list *dl)
npth_mutex_lock (&reader_table_lock); npth_mutex_lock (&reader_table_lock);
while (dl->idx < dl->idx_max) while (dl->idx < dl->idx_max)
{ {
const char *rdrname = pcsc.rdrname[dl->idx]; const char *rdrname = pcsc.rdrname[dl->idx++];
if (DBG_READER) if (DBG_READER)
log_debug ("apdu_open_reader: %s\n", rdrname); log_debug ("apdu_open_reader: %s\n", rdrname);
@ -2270,8 +2270,6 @@ apdu_open_reader (struct dev_list *dl)
continue; continue;
slot = open_pcsc_reader (rdrname); slot = open_pcsc_reader (rdrname);
dl->idx++;
if (slot >= 0) if (slot >= 0)
{ {
npth_mutex_unlock (&reader_table_lock); npth_mutex_unlock (&reader_table_lock);
@ -2284,8 +2282,6 @@ apdu_open_reader (struct dev_list *dl)
continue; continue;
} }
} }
else
dl->idx++;
} }
npth_mutex_unlock (&reader_table_lock); npth_mutex_unlock (&reader_table_lock);