[Pcsclite-cvs-commit] r6748 - trunk/PCSC/src
ludovic.rousseau at free.fr
ludovic.rousseau at free.fr
Tue Sep 10 18:28:46 UTC 2013
Author: rousseau
Date: 2013-09-10 18:28:44 +0000 (Tue, 10 Sep 2013)
New Revision: 6748
Modified:
trunk/PCSC/src/readerfactory.c
trunk/PCSC/src/winscard.c
Log:
Return an error if SCardEndTransaction() is called with no corresponding
SCardBeginTransaction()
This is done in two steps:
- RFUnlockSharing() returns an error if a reader is unlocked when it was
not (or no more) previously locked
- SCardEndTransaction() checks the value returned by RFUnlockSharing()
and returns an error if RFUnlockSharing() failed
Thanks to Markus Heintel for the initial patch
Modified: trunk/PCSC/src/readerfactory.c
===================================================================
--- trunk/PCSC/src/readerfactory.c 2013-09-08 18:33:28 UTC (rev 6747)
+++ trunk/PCSC/src/readerfactory.c 2013-09-10 18:28:44 UTC (rev 6748)
@@ -950,9 +950,14 @@
if (SCARD_S_SUCCESS == rv)
{
if (rContext->LockCount > 0)
+ {
rContext->LockCount -= 1;
- if (0 == rContext->LockCount)
- rContext->hLockId = 0;
+ if (0 == rContext->LockCount)
+ rContext->hLockId = 0;
+ }
+ else
+ /* rContext->LockCount == 0 */
+ rv = SCARD_E_NOT_TRANSACTED;
}
(void)pthread_mutex_unlock(&LockMutex);
Modified: trunk/PCSC/src/winscard.c
===================================================================
--- trunk/PCSC/src/winscard.c 2013-09-08 18:33:28 UTC (rev 6747)
+++ trunk/PCSC/src/winscard.c 2013-09-10 18:28:44 UTC (rev 6748)
@@ -1090,6 +1090,7 @@
LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition)
{
LONG rv;
+ LONG rv2;
READER_CONTEXT * rContext = NULL;
/*
@@ -1213,7 +1214,13 @@
/*
* Unlock any blocks on this context
*/
- (void)RFUnlockSharing(hCard, rContext);
+ /* we do not want to lose the previous rv value
+ * So we use another variable */
+ rv2 = RFUnlockSharing(hCard, rContext);
+ if (rv2 != SCARD_S_SUCCESS)
+ /* if rv is already in error then do not change its value */
+ if (rv == SCARD_S_SUCCESS)
+ rv = rv2;
Log2(PCSC_LOG_DEBUG, "Status: 0x%08lX", rv);
More information about the Pcsclite-cvs-commit
mailing list