[Pcsclite-git-commit] [PCSC] 02/03: SCard: check for a valid hContext handles

Ludovic Rousseau rousseau at moszumanska.debian.org
Fri Dec 30 17:13:03 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 3aaab9d998b5deb16a246cc7517e44144d281d3b
Author: Peter Wu <peter at lekensteyn.nl>
Date:   Sun Dec 25 23:37:51 2016 +0100

    SCard: check for a valid hContext handles
    
    Reject invalid (zero) hContext handles and log the event.
---
 src/winscard_svc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/winscard_svc.c b/src/winscard_svc.c
index 406030f..95bb264 100644
--- a/src/winscard_svc.c
+++ b/src/winscard_svc.c
@@ -815,6 +815,12 @@ static LONG MSGRemoveContext(SCARDCONTEXT hContext, SCONTEXT * threadContext)
 	LONG rv;
 	int lrv;
 
+	if (0 == threadContext->hContext)
+	{
+		Log1(PCSC_LOG_ERROR, "Invalidated handle");
+		return SCARD_E_INVALID_HANDLE;
+	}
+
 	if (threadContext->hContext != hContext)
 		return SCARD_E_INVALID_VALUE;
 
@@ -894,6 +900,12 @@ static LONG MSGAddHandle(SCARDCONTEXT hContext, SCARDHANDLE hCard,
 {
 	LONG retval = SCARD_E_INVALID_VALUE;
 
+	if (0 == threadContext->hContext)
+	{
+		Log1(PCSC_LOG_ERROR, "Invalidated handle");
+		return SCARD_E_INVALID_HANDLE;
+	}
+
 	if (threadContext->hContext == hContext)
 	{
 		/*
@@ -933,6 +945,7 @@ static LONG MSGAddHandle(SCARDCONTEXT hContext, SCARDHANDLE hCard,
 	return retval;
 }
 
+/* Pre-condition: MSGCheckHandleAssociation must succeed. */
 static LONG MSGRemoveHandle(SCARDHANDLE hCard, SCONTEXT * threadContext)
 {
 	int lrv;

-- 
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