[Pcsclite-git-commit] [PCSC] 01/01: SCardGetStatusChange(): Fix a (rare) race condition

Ludovic Rousseau rousseau at moszumanska.debian.org
Tue Dec 6 16:58:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository PCSC.

commit 4e2a563c8ed4353ad013de85b71aac12ec599f82
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Tue Dec 6 16:47:43 2016 +0100

    SCardGetStatusChange(): Fix a (rare) race condition
    
    " After the client timed out it sends a CMD_STOP_WAITING_READER_STATE_CHANGE.
    Sometimes an event occurs which triggers MSGSignalClient, which unregisters the
    client from events and sends a wait_reader_state_change message to the client.
    The client interprets this message as an answer to its
    CMD_STOP_WAITING_READER_STATE_CHANGE.
    
    If we send another wait_reader_state_change message to the client it stays in
    its buffer until another Command is issued and this message appears as leading
    garbage in the commands answer.
    
    Therefore we should not send the wait_reader_state_change message here, if the
    client has already been unregisterd from events. "
    
    Thanks to Florian Kaiser for the patch
    "[Pcsclite-muscle] [PATCH] fix racecondition between winscard server and clients"
    http://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20161128/000772.html
---
 src/winscard_svc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/winscard_svc.c b/src/winscard_svc.c
index dae9f85..1ddbc5a 100644
--- a/src/winscard_svc.c
+++ b/src/winscard_svc.c
@@ -422,7 +422,10 @@ static void ContextThread(LPVOID newContext)
 				/* remove the client fd from the list */
 				waStr.rv = EHUnregisterClientForEvent(filedes);
 
-				WRITE_BODY(waStr)
+				/* send the response only if the client was still in the
+				 * list */
+				if (waStr.rv != SCARD_F_INTERNAL_ERROR)
+					WRITE_BODY(waStr)
 			}
 			break;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/PCSC.git



More information about the Pcsclite-cvs-commit mailing list