From f6f80f260a8c088021653b30333beb94104bf87f Mon Sep 17 00:00:00 2001 From: zorgluf Date: Mon, 19 Jul 2021 14:24:05 +0200 Subject: [PATCH] Smartcard MAX_READERS get from pcsclite package --- configure.ac | 8 ++++++++ sesman/chansrv/Makefile.am | 1 + sesman/chansrv/smartcard_pcsc.c | 14 ++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 0081ff4953..4794530013 100644 --- a/configure.ac +++ b/configure.ac @@ -373,6 +373,14 @@ else fi fi +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -I/usr/include/PCSC" +# checking for pcsclite headers +AC_CHECK_HEADER([PCSC/pcsclite.h], [], + [AC_MSG_ERROR([please install libpcsclite-dev or pcsc-lite-dev])]) + +CFLAGS="$save_CFLAGS" + AC_PATH_XTRA if test "x$no_x" == "xyes"; then AC_MSG_ERROR([please install libx11-dev or libX11-devel]) diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am index 4f74912c48..8e97e32d58 100644 --- a/sesman/chansrv/Makefile.am +++ b/sesman/chansrv/Makefile.am @@ -9,6 +9,7 @@ AM_CPPFLAGS = \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \ -DXRDP_SOCKET_PATH=\"${socketdir}\" \ + -I/usr/include/PCSC \ -I$(top_srcdir)/common CHANSRV_EXTRA_LIBS = diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index f294530d66..fb164645de 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -43,13 +43,11 @@ #include "list.h" #include "defines.h" #include "xrdp_sockets.h" +#include "PCSC/pcsclite.h" #if PCSC_STANDIN -#define MAX_ATR_SIZE 33 -#define MAX_READERS 32 - extern int g_display_num; /* in chansrv.c */ static int g_autoinc = 0; /* general purpose autoinc */ @@ -93,9 +91,9 @@ struct pcsc_uds_client int state; int pad1; - PCSC_READER_STATE readerStates[MAX_READERS]; - tui32 current_states[MAX_READERS]; - tui32 event_states[MAX_READERS]; + PCSC_READER_STATE readerStates[PCSCLITE_MAX_READERS_CONTEXTS]; + tui32 current_states[PCSCLITE_MAX_READERS_CONTEXTS]; + tui32 event_states[PCSCLITE_MAX_READERS_CONTEXTS]; int numReaders; int waiting; int something_changed; @@ -748,7 +746,7 @@ scard_readers_to_list(struct pcsc_uds_client *uds_client, } reader_index++; hold_reader = uds_client->readerStates[reader_index]; - if (reader_index > (MAX_READERS - 1)) + if (reader_index > (PCSCLITE_MAX_READERS_CONTEXTS - 1)) { return 0; } @@ -763,7 +761,7 @@ scard_readers_to_list(struct pcsc_uds_client *uds_client, } uds_client->numReaders = reader_index; /* clear the rest */ - while (reader_index < MAX_READERS) + while (reader_index < PCSCLITE_MAX_READERS_CONTEXTS) { g_memset(uds_client->readerStates + reader_index, 0, sizeof(PCSC_READER_STATE)); uds_client->current_states[reader_index] = 0;