[Pcsclite-cvs-commit] PCSC/src winscard_clnt.c,1.25,1.26

rousseau@quantz.debian.org rousseau@quantz.debian.org
Fri, 23 Jan 2004 11:54:23 +0100


Update of /cvsroot/pcsclite/PCSC/src
In directory quantz:/tmp/cvs-serv32264/src

Modified Files:
	winscard_clnt.c 
Log Message:
check that psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName is non NULL before accessing it in strcmp()


Index: winscard_clnt.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/winscard_clnt.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- winscard_clnt.c	22 Jan 2004 14:32:07 -0000	1.25
+++ winscard_clnt.c	23 Jan 2004 10:54:21 -0000	1.26
@@ -189,7 +189,7 @@
 				 * Initially set the hcard structs to zero
 				 */
 				psContextMap[i].psChannelMap[j].hCard = 0;
-				psContextMap[i].psChannelMap[j].readerName = 0;
+				psContextMap[i].psChannelMap[j].readerName = NULL;
 			}
 		}
 
@@ -494,11 +494,11 @@
 
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
-		if (strcmp(psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
-				(readerStates[i])->readerName) == 0)
-		{
+		char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;
+
+		/* by default r == NULL */
+		if (r && strcmp(r, (readerStates[i])->readerName) == 0)
 			break;
-		}
 	}
 
 	if (i == PCSCLITE_MAX_READERS_CONTEXTS)
@@ -642,11 +642,11 @@
 
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
-		if (strcmp(psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
-				(readerStates[i])->readerName) == 0)
-		{
+		char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;
+
+		/* by default r == NULL */
+		if (r && strcmp(r, (readerStates[i])->readerName) == 0)
 			break;
-		}
 	}
 
 	if (i == PCSCLITE_MAX_READERS_CONTEXTS)
@@ -756,11 +756,11 @@
 
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
-		if (strcmp(psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
-				(readerStates[i])->readerName) == 0)
-		{
+		char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;
+
+		/* by default r == NULL */
+		if (r && strcmp(r, (readerStates[i])->readerName) == 0)
 			break;
-		}
 	}
 
 	if (i == PCSCLITE_MAX_READERS_CONTEXTS)
@@ -835,11 +835,11 @@
 
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
-		if (strcmp(psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
-				(readerStates[i])->readerName) == 0)
-		{
+		char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;
+
+		/* by default r == NULL */
+		if (r && strcmp(r, (readerStates[i])->readerName) == 0)
 			break;
-		}
 	}
 
 	if (i == PCSCLITE_MAX_READERS_CONTEXTS)
@@ -928,11 +928,11 @@
 
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
-		if (strcmp(psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
-				(readerStates[i])->readerName) == 0)
-		{
+		char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;
+
+		/* by default r == NULL */
+		if (r && strcmp(r, (readerStates[i])->readerName) == 0)
 			break;
-		}
 	}
 
 	if (i == PCSCLITE_MAX_READERS_CONTEXTS)
@@ -1539,11 +1539,11 @@
 
 	for (i = 0; i < PCSCLITE_MAX_READERS_CONTEXTS; i++)
 	{
-		if (strcmp(psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
-				(readerStates[i])->readerName) == 0)
-		{
+		char *r = psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName;
+
+		/* by default r == NULL */
+		if (r && strcmp(r, (readerStates[i])->readerName) == 0)
 			break;
-		}
 	}
 
 	if (i == PCSCLITE_MAX_READERS_CONTEXTS)
@@ -1855,7 +1855,7 @@
 			 */
 			psContextMap[retIndice].psChannelMap[i].hCard = 0;
 			free(psContextMap[retIndice].psChannelMap[i].readerName);
-			psContextMap[retIndice].psChannelMap[i].readerName = 0;
+			psContextMap[retIndice].psChannelMap[i].readerName = NULL;
 		}
 
 		return SCARD_S_SUCCESS;
@@ -1896,7 +1896,7 @@
 	{
 		psContextMap[dwContextIndice].psChannelMap[dwChannelIndice].hCard = 0;
 		free(psContextMap[dwContextIndice].psChannelMap[dwChannelIndice].readerName);
-		psContextMap[dwContextIndice].psChannelMap[dwChannelIndice].readerName = 0;
+		psContextMap[dwContextIndice].psChannelMap[dwChannelIndice].readerName = NULL;
 		return SCARD_S_SUCCESS;
 	}
 }