[Pcsclite-git-commit] [pcsc-tools] 01/01: Handle "simultaneous" readers removal

Ludovic Rousseau rousseau at moszumanska.debian.org
Mon Jun 27 16:45:34 UTC 2016


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

rousseau pushed a commit to branch master
in repository pcsc-tools.

commit b10d9dc1634939fc16ae590d1fce04667be2b2b7
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Mon Jun 27 11:02:17 2016 +0200

    Handle "simultaneous" readers removal
    
    When a multi slot reader (say with 2 slots) is removed then
    SCardGetStatusChange() will return with .dwEventState bit
    SCARD_STATE_CHANGED set for the first slot. Then the present readers are
    enumerated again and the second slot may still be listed by pcscd at
    that time.
    
    But when SCardGetStatusChange() is called again then the second slot may
    have been removed by pcscd and SCardGetStatusChange() will fail and
    return SCARD_E_UNKNOWN_READER.
    
    This a toctou (Time of check to time of use) issue between
    SCardListReaders() call and SCardGetStatusChange() call.
    
    Before the change the command pcsc_scan just exited with an error
    message: SCardGetStatusChange: Unknown reader specified.
    
    No the readers are re-enumerated and the loop continues.
---
 pcsc_scan.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pcsc_scan.c b/pcsc_scan.c
index 6b1f102..13291b4 100644
--- a/pcsc_scan.c
+++ b/pcsc_scan.c
@@ -429,6 +429,10 @@ get_readers:
 			nbReaders);
 	} /* while */
 
+	/* A reader disappeared */
+	if (SCARD_E_UNKNOWN_READER == rv)
+		goto get_readers;
+
 	/* If we get out the loop, GetStatusChange() was unsuccessful */
 	test_rv("SCardGetStatusChange", rv, hContext);
 

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



More information about the Pcsclite-cvs-commit mailing list