[Pcsclite-git-commit] [PCSC] 03/06: RFUnlockSharing: handle SCARD_SHARE_EXCLUSIVE
Ludovic Rousseau
rousseau at moszumanska.debian.org
Fri May 20 16:12:51 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 b7a4f8f47c1c57b56dfe6cd1088f68b845016d9b
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date: Fri May 20 16:19:56 2016 +0200
RFUnlockSharing: handle SCARD_SHARE_EXCLUSIVE
When a card is connected using SCARD_SHARE_EXCLUSIVE then
RFUnlockSharing() called by SCardEndTransaction() should not be able to
remove the exclusive access.
The bug was detected because the following sequence worked but should
not:
SCardConnect(..., SCARD_SHARE_EXCLUSIVE, ...);
SCardEndTransaction();
An error was reported only on the second SCardEndTransaction() call.
Now the first call to SCardEndTransaction() will fail and the card
connection will stay exclusive.
Thanks to Christophe Ferrando for the bug report in "[Pcsclite-muscle]
SCARD_E_NOT_TRANSACTED"
http://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20160516/000598.html
---
src/readerfactory.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/readerfactory.c b/src/readerfactory.c
index df855ea..026ceea 100644
--- a/src/readerfactory.c
+++ b/src/readerfactory.c
@@ -1027,15 +1027,25 @@ LONG RFUnlockSharing(SCARDHANDLE hCard, READER_CONTEXT * rContext)
rv = RFCheckSharing(hCard, rContext);
if (SCARD_S_SUCCESS == rv)
{
- if (rContext->LockCount > 0)
+ if (PCSCLITE_SHARING_EXCLUSIVE_CONTEXT == rContext->contexts)
{
- rContext->LockCount -= 1;
- if (0 == rContext->LockCount)
- rContext->hLockId = 0;
+ if (rContext->LockCount > 1)
+ rContext->LockCount -= 1;
+ else
+ rv = SCARD_E_NOT_TRANSACTED;
}
else
- /* rContext->LockCount == 0 */
- rv = SCARD_E_NOT_TRANSACTED;
+ {
+ if (rContext->LockCount > 0)
+ {
+ rContext->LockCount -= 1;
+ if (0 == rContext->LockCount)
+ rContext->hLockId = 0;
+ }
+ else
+ /* rContext->LockCount == 0 */
+ rv = SCARD_E_NOT_TRANSACTED;
+ }
}
(void)pthread_mutex_unlock(&LockMutex);
--
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