[server,proxy] check for nullptr before using scard_call_context

* Make smartcard_call_cancel_all_context return FALSE if a NULL context
  is supplied.

* Do not call smartcard_call_context_signal_stop if the context is NULL
This commit is contained in:
Armin Novak
2026-03-02 09:45:27 +01:00
parent d9e1b494d6
commit cc5f1bbb82
3 changed files with 14 additions and 3 deletions

View File

@@ -44,6 +44,13 @@ extern "C"
WINPR_ATTR_NODISCARD
FREERDP_API scard_call_context* smartcard_call_context_new(const rdpSettings* settings);
/** @brief send a stop signal (or reset it if \b reset is \b TRUE) to a \ref scard_call_context
*
* @param ctx The context to send the signal to. Must not be \b nullptr
* @param reset Set or reset the signal
*
* @return \b TRUE for success, \b FALSE otherwise.
*/
FREERDP_API BOOL smartcard_call_context_signal_stop(scard_call_context* ctx, BOOL reset);
WINPR_ATTR_NODISCARD

View File

@@ -2051,7 +2051,8 @@ BOOL smartcard_call_release_context(scard_call_context* ctx, SCARDCONTEXT hConte
BOOL smartcard_call_cancel_all_context(scard_call_context* ctx)
{
WINPR_ASSERT(ctx);
if (!ctx)
return FALSE;
smartcard_call_context_signal_stop(ctx, FALSE);
HashTable_Clear(ctx->rgSCardContextList);
@@ -2094,6 +2095,7 @@ BOOL smartcard_call_is_configured(scard_call_context* ctx)
BOOL smartcard_call_context_signal_stop(scard_call_context* ctx, BOOL reset)
{
WINPR_ASSERT(ctx);
if (!ctx->stopEvent)
return TRUE;

View File

@@ -271,7 +271,8 @@ BOOL pf_channel_smartcard_server_handle(WINPR_ATTR_UNUSED pServerContext* ps,
static void channel_stop_and_wait(pf_channel_client_context* scard, BOOL reset)
{
WINPR_ASSERT(scard);
smartcard_call_context_signal_stop(scard->callctx, FALSE);
if (scard->callctx)
smartcard_call_context_signal_stop(scard->callctx, FALSE);
while (ArrayList_Count(scard->workObjects) > 0)
{
@@ -281,7 +282,8 @@ static void channel_stop_and_wait(pf_channel_client_context* scard, BOOL reset)
WaitForThreadpoolWorkCallbacks(work, TRUE);
}
smartcard_call_context_signal_stop(scard->callctx, reset);
if (scard->callctx)
smartcard_call_context_signal_stop(scard->callctx, reset);
}
static void pf_channel_scard_client_context_free(InterceptContextMapEntry* base)