From f63ee99ad515580763198e773a67f50ed0af41cd Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Fri, 3 Nov 2023 17:50:53 +0100 Subject: [PATCH] SCardCancel(): return SCARD_S_SUCCESS even if the client already finished MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases SCardCancel() is called exactly at the same time SCardGetStatusChange() exits with SCARD_E_TIMEOUT. In that case the SCardGetStatusChange() client disapears in the middle of SCardCancel() processing. If the client is found but can't be contacted then we return SCARD_S_SUCCESS instead of SCARD_E_INVALID_HANDLE. Thanks to Jakub Janků for the bug report Closes: https://github.com/LudovicRousseau/PCSC/issues/160 "Concurrency issue with SCardCancel and SCardGetStatusChange timeout #160" --- src/winscard_svc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/winscard_svc.c b/src/winscard_svc.c index a430474b..e59d09fb 100644 --- a/src/winscard_svc.c +++ b/src/winscard_svc.c @@ -621,6 +621,8 @@ static void * ContextThread(LPVOID newContext) /* signal the client only if it was still waiting */ if (SCARD_S_SUCCESS == rv) caStr.rv = MSGSignalClient(fd, SCARD_E_CANCELLED); + else + caStr.rv = SCARD_S_SUCCESS; } WRITE_BODY(caStr);