From 4b7208fb6e046123b2cb918eb1d30be966f8a38a Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 8 Feb 2021 16:42:40 +0100 Subject: [PATCH] Always return data on SCardGetStatusChange If the call fails just return empty data for each reader. --- channels/smartcard/client/smartcard_operations.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index 01680474b..4639b1778 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -1275,6 +1275,7 @@ static LONG smartcard_GetStatusChangeW_Decode(SMARTCARD_DEVICE* smartcard, static LONG smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATION* operation) { + LONG status; UINT32 index; GetStatusChange_Return ret = { 0 }; LPSCARD_READERSTATEW rgReaderState = NULL; @@ -1303,7 +1304,7 @@ static LONG smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard, sizeof(ret.rgReaderStates[index].rgbAtr)); } - smartcard_pack_get_status_change_return(smartcard, irp->output, &ret, TRUE); + status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret, TRUE); if (call->rgReaderStates) { @@ -1317,6 +1318,8 @@ static LONG smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard, } free(ret.rgReaderStates); + if (status != SCARD_S_SUCCESS) + return status; return ret.ReturnCode; } @@ -2061,11 +2064,6 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard, SCardGetStatusChangeA(operation->hContext, 0x000001F4, states, call->cReaders); log_status_error(TAG, "SCardGetStatusChangeA", status); - if (status && (status != SCARD_E_TIMEOUT) && (status != SCARD_E_CANCELLED)) - { - call->cReaders = 0; - } - for (i = 0; i < call->cAtrs; i++) { for (j = 0; j < call->cReaders; j++) @@ -2108,8 +2106,6 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard, free(states); status = smartcard_pack_get_status_change_return(smartcard, irp->output, &ret, FALSE); - if (status != SCARD_S_SUCCESS) - return status; if (call->rgReaderStates) { @@ -2129,6 +2125,8 @@ static LONG smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard, } free(ret.rgReaderStates); + if (status != SCARD_S_SUCCESS) + return status; return ret.ReturnCode; }