mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-20 14:37:08 +01:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
5996c7bf99
commit
da4c132cca
12
scd/apdu.c
12
scd/apdu.c
@ -3127,7 +3127,7 @@ apdu_open_one_reader (const char *portstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
apdu_open_reader (struct dev_list *dl)
|
apdu_open_reader (struct dev_list *dl, int app_empty)
|
||||||
{
|
{
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
@ -3177,6 +3177,7 @@ apdu_open_reader (struct dev_list *dl)
|
|||||||
/* Check identity by BAI against already opened HANDLEs. */
|
/* Check identity by BAI against already opened HANDLEs. */
|
||||||
for (slot = 0; slot < MAX_READER; slot++)
|
for (slot = 0; slot < MAX_READER; slot++)
|
||||||
if (reader_table[slot].used
|
if (reader_table[slot].used
|
||||||
|
&& reader_table[slot].ccid.handle
|
||||||
&& ccid_compare_BAI (reader_table[slot].ccid.handle, bai))
|
&& ccid_compare_BAI (reader_table[slot].ccid.handle, bai))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3201,12 +3202,19 @@ apdu_open_reader (struct dev_list *dl)
|
|||||||
dl->idx++;
|
dl->idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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;
|
slot = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{ /* PC/SC readers. */
|
{ /* PC/SC readers. */
|
||||||
if (dl->idx == 0)
|
if (app_empty && dl->idx == 0)
|
||||||
{
|
{
|
||||||
dl->idx++;
|
dl->idx++;
|
||||||
slot = apdu_open_one_reader (dl->portstr);
|
slot = apdu_open_one_reader (dl->portstr);
|
||||||
|
@ -91,7 +91,7 @@ gpg_error_t apdu_dev_list_start (const char *portstr, struct dev_list **l_p);
|
|||||||
void apdu_dev_list_finish (struct dev_list *l);
|
void apdu_dev_list_finish (struct dev_list *l);
|
||||||
|
|
||||||
/* Note, that apdu_open_reader returns no status word but -1 on error. */
|
/* Note, that apdu_open_reader returns no status word but -1 on error. */
|
||||||
int apdu_open_reader (struct dev_list *l);
|
int apdu_open_reader (struct dev_list *l, int app_empty);
|
||||||
int apdu_open_remote_reader (const char *portstr,
|
int apdu_open_remote_reader (const char *portstr,
|
||||||
const unsigned char *cookie, size_t length,
|
const unsigned char *cookie, size_t length,
|
||||||
int (*readfnc) (void *opaque,
|
int (*readfnc) (void *opaque,
|
||||||
|
@ -343,7 +343,7 @@ select_application (ctrl_t ctrl, const char *name, app_t *r_app,
|
|||||||
int slot;
|
int slot;
|
||||||
int periodical_check_needed_this;
|
int periodical_check_needed_this;
|
||||||
|
|
||||||
slot = apdu_open_reader (l);
|
slot = apdu_open_reader (l, !app_top);
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user