summaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2017-04-07 05:18:16 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2017-04-07 05:18:16 +0200
commit3c93595d701c59cbc9b67a7fd0bcde7ee0fada1a (patch)
tree0ca311f780547bfab1149c664c7b32785c6a8d36 /scd
parentagent: Serialize access to passphrase cache. (diff)
downloadgnupg2-3c93595d701c59cbc9b67a7fd0bcde7ee0fada1a.tar.xz
gnupg2-3c93595d701c59cbc9b67a7fd0bcde7ee0fada1a.zip
scd: Don't keep CCID reader open when card is not available.
* scd/apdu.c (open_ccid_reader): Fail if no ATR. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd')
-rw-r--r--scd/apdu.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index 147bf7382..65f770dfd 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -1496,6 +1496,9 @@ open_ccid_reader (struct dev_list *dl)
err = ccid_open_reader (dl->portstr, dl->idx, dl->ccid_table,
&slotp->ccid.handle, &slotp->rdrname);
+ if (!err)
+ err = ccid_get_atr (slotp->ccid.handle,
+ slotp->atr, sizeof slotp->atr, &slotp->atrlen);
if (err)
{
slotp->used = 0;
@@ -1503,14 +1506,6 @@ open_ccid_reader (struct dev_list *dl)
return -1;
}
- err = ccid_get_atr (slotp->ccid.handle,
- slotp->atr, sizeof slotp->atr, &slotp->atrlen);
- if (err)
- {
- slotp->atrlen = 0;
- err = 0;
- }
-
require_get_status = ccid_require_get_status (slotp->ccid.handle);
reader_table[slot].close_reader = close_ccid_reader;