Skip to content

Commit

Permalink
Smartcard fix for pcsclite 1.8.23+
Browse files Browse the repository at this point in the history
  • Loading branch information
zorgluf authored and Cloud User committed Jul 21, 2021
1 parent 3622691 commit 49503d2
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions sesman/chansrv/smartcard_pcsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct pcsc_uds_client
int waiting;
int something_changed;
int send_status;
int version;
};

static struct list *g_uds_clients = 0; /* struct pcsc_uds_client */
Expand Down Expand Up @@ -1638,19 +1639,19 @@ static int
scard_process_cmd_version(struct trans *con, struct stream *in_s)
{
int rv;
int major;
int minor;
int major = 0;
int minor = 0;
struct pcsc_uds_client *uds_client;
void *user_data;

LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_process_version:");
rv = 0;
in_uint32_le(in_s, major);
in_uint32_le(in_s, minor);
LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_process_version: major %d minor %d", major, minor);
LOG_DEVEL(LOG_LEVEL_INFO, "scard_process_version: major %d minor %d", major, minor);
uds_client = (struct pcsc_uds_client *) (con->callback_data);
uds_client->state = 1;
uds_client = (struct pcsc_uds_client *) (con->callback_data);
uds_client->version = major * 1000 + minor;
user_data = (void *) (tintptr) (uds_client->uds_client_id);
uds_client->ref_count++;
scard_send_establish_context(user_data, 0); /* SCARD_SCOPE_USER */
Expand Down Expand Up @@ -1686,18 +1687,30 @@ scard_process_cmd_wait_reader_state_change(struct trans *con,
struct stream *in_s)
{
int rv;
//struct stream *out_s;
int timeOut;
int timeOut __attribute__((unused));
int reader_state_bytes;
struct stream *out_s;
struct pcsc_uds_client *uds_client;

LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_process_cmd_wait_reader_state_change:");
in_uint32_le(in_s, timeOut);
LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_process_cmd_wait_reader_state_change: timeOut %d",
timeOut);
//out_s = con->out_s;
uds_client = (struct pcsc_uds_client *) (con->callback_data);
uds_client->waiting = 1;
rv = 0;
if (uds_client->version > 4002) {
//In these versions, return reader states immediately
out_s = con->out_s;
reader_state_bytes = sizeof(uds_client->readerStates);
init_stream(out_s, reader_state_bytes);
out_uint8a(out_s, uds_client->readerStates, reader_state_bytes);
s_mark_end(out_s);
rv = trans_write_copy(con);
} else {
in_uint32_le(in_s, timeOut);
LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_process_cmd_wait_reader_state_change: timeOut %d",
timeOut);
in_uint32_le(in_s, rv);
LOG_DEVEL(LOG_LEVEL_DEBUG, "scard_process_cmd_wait_reader_state_change: rv %d", rv);
}

return rv;
}

Expand Down

0 comments on commit 49503d2

Please sign in to comment.