diff options
Diffstat (limited to 'scd/apdu.c')
-rw-r--r-- | scd/apdu.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scd/apdu.c b/scd/apdu.c index f6cca8c7b..189fd4afa 100644 --- a/scd/apdu.c +++ b/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; |