[Pcsclite-cvs-commit] r4744 - in /trunk/PCSC/src: readerfactory.c readerfactory.h

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Tue Feb 9 15:39:08 UTC 2010


Author: rousseau
Date: Tue Feb  9 15:39:08 2010
New Revision: 4744

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4744
Log:
use a dynamic instead of static allocation for lpcDevice

Modified:
    trunk/PCSC/src/readerfactory.c
    trunk/PCSC/src/readerfactory.h

Modified: trunk/PCSC/src/readerfactory.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.c?rev=4744&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.c (original)
+++ trunk/PCSC/src/readerfactory.c Tue Feb  9 15:39:08 2010
@@ -111,14 +111,6 @@
 		return SCARD_E_INVALID_VALUE;
 	}
 
-	/* Device name too long? */
-	if (strlen(lpcDevice) >= MAX_DEVICENAME)
-	{
-		Log3(PCSC_LOG_ERROR, "Device name too long: %d chars instead of max %d",
-			strlen(lpcDevice), MAX_DEVICENAME);
-		return SCARD_E_INVALID_VALUE;
-	}
-
 	/* Same name, same port - duplicate reader cannot be used */
 	if (dwNumReadersContexts != 0)
 	{
@@ -168,8 +160,7 @@
 		return SCARD_E_NO_MEMORY;
 
 	sReadersContexts[dwContext]->lpcLibrary = strdup(lpcLibrary);
-	(void)strlcpy((sReadersContexts[dwContext])->lpcDevice, lpcDevice,
-		sizeof((sReadersContexts[dwContext])->lpcDevice));
+	sReadersContexts[dwContext]->lpcDevice = strdup(lpcDevice);
 	(sReadersContexts[dwContext])->version = 0;
 	(sReadersContexts[dwContext])->port = port;
 	(sReadersContexts[dwContext])->mMutex = NULL;
@@ -339,8 +330,8 @@
 
 		sReadersContexts[dwContextB]->lpcLibrary =
 			sReadersContexts[dwContext]->lpcLibrary;
-		(void)strlcpy((sReadersContexts[dwContextB])->lpcDevice, lpcDevice,
-			sizeof((sReadersContexts[dwContextB])->lpcDevice));
+		sReadersContexts[dwContextB]->lpcDevice =
+			sReadersContexts[dwContext]->lpcDevice;
 		(sReadersContexts[dwContextB])->version =
 		  (sReadersContexts[dwContext])->version;
 		(sReadersContexts[dwContextB])->port =
@@ -472,6 +463,7 @@
 			(void)SYS_MutexDestroy(sContext->mMutex);
 			free(sContext->mMutex);
 			free(sContext->lpcLibrary);
+			free(sContext->lpcDevice);
 		}
 
 		*sContext->pMutex -= 1;
@@ -492,7 +484,6 @@
 			sContext->pFeeds = NULL;
 		}
 
-		sContext->lpcDevice[0] = 0;
 		sContext->version = 0;
 		sContext->port = 0;
 		sContext->mMutex = NULL;

Modified: trunk/PCSC/src/readerfactory.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.h?rev=4744&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.h (original)
+++ trunk/PCSC/src/readerfactory.h Tue Feb  9 15:39:08 2010
@@ -107,7 +107,7 @@
 	{
 		char lpcReader[MAX_READERNAME];	/**< Reader Name */
 		char *lpcLibrary;	/**< Library Path */
-		char lpcDevice[MAX_DEVICENAME];	/**< Device Name */
+		char *lpcDevice;	/**< Device Name */
 		PCSCLITE_THREAD_T pthThread;	/**< Event polling thread */
 		RESPONSECODE (*pthCardEvent)(DWORD);	/**< Card Event sync */
 		PCSCLITE_MUTEX *mMutex;	/**< Mutex for this connection */




More information about the Pcsclite-cvs-commit mailing list