[git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.27-17-g3f9f33b
by NIIBE Yutaka
cvs at cvs.gnupg.org
Fri May 1 07:35:50 CEST 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".
The branch, STABLE-BRANCH-2-0 has been updated
via 3f9f33bbcb40146c6f09277a28d499188ed34ef2 (commit)
from 43429c7869152f301157e4b24790b3801dce0f0a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3f9f33bbcb40146c6f09277a28d499188ed34ef2
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Thu Apr 30 12:36:38 2015 +0900
scd: PC/SC reader selection by partial string match.
* scd/apdu.c (open_pcsc_reader_direct): Partial string match.
* scd/pcsc-wrapper.c (handle_open): Likewise.
--
(backport from 2.1 commit 01a2a61bc4b34817c4216888265f65d59a33dad3)
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.
GnuPG-bug-id: 1618, 1930
diff --git a/scd/apdu.c b/scd/apdu.c
index 6fc1148..72b291e 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -1870,7 +1870,8 @@ open_pcsc_reader_direct (const char *portstr)
long err;
int slot;
char *list = NULL;
- pcsc_dword_t nreader, listlen;
+ char *rdrname = NULL;
+ pcsc_dword_t nreader;
char *p;
slot = new_reader_slot ();
@@ -1917,24 +1918,27 @@ open_pcsc_reader_direct (const char *portstr)
return -1;
}
- listlen = nreader;
p = list;
while (nreader)
{
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");
@@ -1943,7 +1947,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;
diff --git a/scd/pcsc-wrapper.c b/scd/pcsc-wrapper.c
index 4dc44ee..b83e218 100644
--- a/scd/pcsc-wrapper.c
+++ b/scd/pcsc-wrapper.c
@@ -406,8 +406,9 @@ static void
handle_open (unsigned char *argbuf, size_t arglen)
{
long err;
- const char * portstr;
+ const char *portstr;
char *list = NULL;
+ char *rdrname = NULL;
pcsc_dword_t nreader, atrlen;
char *p;
pcsc_dword_t card_state, card_protocol;
@@ -416,7 +417,10 @@ handle_open (unsigned char *argbuf, size_t arglen)
/* Make sure there is only the port string */
if (arglen != strlen ((char*)argbuf))
bad_request ("OPEN");
- portstr = (char*)argbuf;
+ if (arglen == 0)
+ portstr = NULL;
+ else
+ portstr = (char*)argbuf;
if (driver_is_open)
{
@@ -466,17 +470,21 @@ handle_open (unsigned char *argbuf, size_t arglen)
fprintf (stderr, PGM": 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;
}
- current_rdrname = malloc (strlen (portstr && *portstr? portstr:list)+1);
+ if (!rdrname)
+ rdrname = list;
+
+ current_rdrname = strdup (rdrname);
if (!current_rdrname)
{
fprintf (stderr, PGM": error allocating memory for reader name\n");
exit (1);
}
- strcpy (current_rdrname, portstr && *portstr? portstr:list);
free (list);
err = pcsc_connect (pcsc_context,
-----------------------------------------------------------------------
Summary of changes:
scd/apdu.c | 15 +++++++++------
scd/pcsc-wrapper.c | 16 ++++++++++++----
2 files changed, 21 insertions(+), 10 deletions(-)
hooks/post-receive
--
The GNU Privacy Guard
http://git.gnupg.org
More information about the Gnupg-commits
mailing list