[Pcsclite-git-commit] [PCSC] 03/04: SCardGetStatusChange(): fix card movement bug
Ludovic Rousseau
rousseau at moszumanska.debian.org
Fri Jun 26 15:39:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
rousseau pushed a commit to branch master
in repository PCSC.
commit 75652c447c9d2b2f042fe01fbbcff40c79902e05
Author: Ludovic Rousseau <ludovic.rousseau at gmail.com>
Date: Fri Jun 26 15:03:00 2015 +0200
SCardGetStatusChange(): fix card movement bug
The card movement counter eventCounter is a uint32_t and this value is
also storded in the upper 16 bits of dwEventState.
dwEventState should be copied in dwCurrentState by the application
before the next call to SCardGetStatusChange().
The upper 16 bits of dwCurrentState are then compared to eventCounter to
detect a card movement.
The alrogithm works fine if eventCounter can be stored on a 16-bits
integer. The function SCardGetStatusChange() will return immediatly if
eventCounter is greater than 2^16 even if no card movement happened.
This is because eventCounter will always be different to the lowest
16-bits of eventCounter stored in dwCurrentState.
The patch resets eventCounter to 0 after 0xFFFF so its value can always
be stored in a 16-bits integer.
Thanks to Alan for the bug report
https://alioth.debian.org/tracker/index.php?func=detail&aid=314929&group_id=30105&atid=410085
[#314929] logic error in the implementation of the READER_STATE.eventCounter feature
---
src/eventhandler.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/eventhandler.c b/src/eventhandler.c
index d3b2a25..ac9675b 100644
--- a/src/eventhandler.c
+++ b/src/eventhandler.c
@@ -366,6 +366,8 @@ static void EHStatusHandlerThread(READER_CONTEXT * rContext)
dwCurrentState = SCARD_ABSENT;
rContext->readerState->eventCounter++;
+ if (rContext->readerState->eventCounter > 0xFFFF)
+ rContext->readerState->eventCounter = 0;
(void)EHSignalEventToClients();
}
@@ -414,6 +416,8 @@ static void EHStatusHandlerThread(READER_CONTEXT * rContext)
dwCurrentState = SCARD_PRESENT;
rContext->readerState->eventCounter++;
+ if (rContext->readerState->eventCounter > 0xFFFF)
+ rContext->readerState->eventCounter = 0;
Log2(PCSC_LOG_INFO, "Card inserted into %s", readerName);
--
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