aboutsummaryrefslogtreecommitdiffstats
path: root/scd/apdu.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2017-02-13 02:09:13 +0000
committerNIIBE Yutaka <[email protected]>2017-02-13 02:09:13 +0000
commitda4c132cca2c6df81243c9660b7348268a848f88 (patch)
treeb3ac676f9f4aa45d1a1b7ae3f09d17d595bbfc5c /scd/apdu.c
parentgpg: Fix memory leak in the error case of signature creation. (diff)
downloadgnupg-da4c132cca2c6df81243c9660b7348268a848f88.tar.gz
gnupg-da4c132cca2c6df81243c9660b7348268a848f88.zip
scd: Fix use case of PC/SC.
* scd/apdu.c (apdu_open_reader): Add an argument APP_EMPTY. When CCID driver fails to open, try PC/SC if APP is nothing. * scd/app.c (select_application): Supply arg if APP is nothing. -- After scanning available card readers by CCID driver, scdaemon should try PC/SC service if no APP is registered yet. Also, when the slot is allocated for PC/SC (ccid.handle==NULL), it should not call ccid_compare_BAI, otherwise scdaemon crashes. Debian-bug-id: 852702, 854005, 854595, 854616 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to '')
-rw-r--r--scd/apdu.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index 6fc62aa00..82d53b1fa 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -3127,7 +3127,7 @@ apdu_open_one_reader (const char *portstr)
}
int
-apdu_open_reader (struct dev_list *dl)
+apdu_open_reader (struct dev_list *dl, int app_empty)
{
int slot;
@@ -3177,6 +3177,7 @@ apdu_open_reader (struct dev_list *dl)
/* Check identity by BAI against already opened HANDLEs. */
for (slot = 0; slot < MAX_READER; slot++)
if (reader_table[slot].used
+ && reader_table[slot].ccid.handle
&& ccid_compare_BAI (reader_table[slot].ccid.handle, bai))
break;
@@ -3201,12 +3202,19 @@ apdu_open_reader (struct dev_list *dl)
dl->idx++;
}
- slot = -1;
+ /* Not found. Try one for PC/SC, only when it's the initial scan. */
+ if (app_empty && dl->idx == dl->idx_max)
+ {
+ dl->idx++;
+ slot = apdu_open_one_reader (dl->portstr);
+ }
+ else
+ slot = -1;
}
else
#endif
{ /* PC/SC readers. */
- if (dl->idx == 0)
+ if (app_empty && dl->idx == 0)
{
dl->idx++;
slot = apdu_open_one_reader (dl->portstr);