mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
scd: PC/SC reader selection by partial string match.
* scd/apdu.c (open_pcsc_reader_direct): Partial string match. -- The card reader name by PC/SC service might include USB bus, which varies (on some platform like GNU/Linux). Thus, it's better to match partial string. Original patch was submitted by anstein. I changed it to fallback to the first reader if no match found. Note that we need to change pcsc-wrapper.c in 2.0 backport. GnuPG-bug-id: 1618, 1930
This commit is contained in:
parent
172b619348
commit
01a2a61bc4
12
scd/apdu.c
12
scd/apdu.c
@ -1911,6 +1911,7 @@ open_pcsc_reader_direct (const char *portstr)
|
||||
long err;
|
||||
int slot;
|
||||
char *list = NULL;
|
||||
char *rdrname = NULL;
|
||||
pcsc_dword_t nreader;
|
||||
char *p;
|
||||
|
||||
@ -1963,18 +1964,22 @@ open_pcsc_reader_direct (const char *portstr)
|
||||
{
|
||||
if (!*p && !p[1])
|
||||
break;
|
||||
if (*p)
|
||||
log_info ("detected reader '%s'\n", p);
|
||||
log_info ("detected reader '%s'\n", p);
|
||||
if (nreader < (strlen (p)+1))
|
||||
{
|
||||
log_error ("invalid response from pcsc_list_readers\n");
|
||||
break;
|
||||
}
|
||||
if (!rdrname && portstr && !strncmp (p, portstr, strlen (portstr)))
|
||||
rdrname = p;
|
||||
nreader -= strlen (p)+1;
|
||||
p += strlen (p) + 1;
|
||||
}
|
||||
|
||||
reader_table[slot].rdrname = xtrymalloc (strlen (portstr? portstr : list)+1);
|
||||
if (!rdrname)
|
||||
rdrname = list;
|
||||
|
||||
reader_table[slot].rdrname = xtrystrdup (rdrname);
|
||||
if (!reader_table[slot].rdrname)
|
||||
{
|
||||
log_error ("error allocating memory for reader name\n");
|
||||
@ -1983,7 +1988,6 @@ open_pcsc_reader_direct (const char *portstr)
|
||||
unlock_slot (slot);
|
||||
return -1;
|
||||
}
|
||||
strcpy (reader_table[slot].rdrname, portstr? portstr : list);
|
||||
xfree (list);
|
||||
list = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user