[Pcsclite-cvs-commit] r4723 - in /trunk/PCSC/src: pcscd.h.in readerfactory.c readerfactory.h
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Feb 9 10:36:34 UTC 2010
Author: rousseau
Date: Tue Feb 9 10:36:33 2010
New Revision: 4723
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4723
Log:
Use dynamic instead of static allocation for the driver library
filename. The filename is no more limited to 100 characters.
Closes: [#312332] MAX_LIBNAME too short?
Modified:
trunk/PCSC/src/pcscd.h.in
trunk/PCSC/src/readerfactory.c
trunk/PCSC/src/readerfactory.h
Modified: trunk/PCSC/src/pcscd.h.in
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/pcscd.h.in?rev=4723&op=diff
==============================================================================
--- trunk/PCSC/src/pcscd.h.in (original)
+++ trunk/PCSC/src/pcscd.h.in Tue Feb 9 10:36:33 2010
@@ -44,7 +44,6 @@
#define PCSC_MAX_READER_HANDLES 200
#define PCSCLITE_STATUS_WAIT 200000 /**< Status Change Sleep */
-#define MAX_LIBNAME 100
#define MAX_DEVICENAME 255
#define MAX_BUFFER_SIZE 264 /**< Maximum Tx/Rx Buffer for get/set attributes */
Modified: trunk/PCSC/src/readerfactory.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.c?rev=4723&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.c (original)
+++ trunk/PCSC/src/readerfactory.c Tue Feb 9 10:36:33 2010
@@ -111,14 +111,6 @@
return SCARD_E_INVALID_VALUE;
}
- /* Library name too long? */
- if (strlen(lpcLibrary) >= MAX_LIBNAME)
- {
- Log3(PCSC_LOG_ERROR, "Library name too long: %d chars instead of max %d",
- strlen(lpcLibrary), MAX_LIBNAME);
- return SCARD_E_INVALID_VALUE;
- }
-
/* Device name too long? */
if (strlen(lpcDevice) >= MAX_DEVICENAME)
{
@@ -175,8 +167,7 @@
if (parentNode < -1)
return SCARD_E_NO_MEMORY;
- (void)strlcpy((sReadersContexts[dwContext])->lpcLibrary, lpcLibrary,
- sizeof((sReadersContexts[dwContext])->lpcLibrary));
+ sReadersContexts[dwContext]->lpcLibrary = strdup(lpcLibrary);
(void)strlcpy((sReadersContexts[dwContext])->lpcDevice, lpcDevice,
sizeof((sReadersContexts[dwContext])->lpcDevice));
(sReadersContexts[dwContext])->dwVersion = 0;
@@ -347,8 +338,8 @@
sizeof(sReadersContexts[dwContextB]->lpcReader));
sprintf(tmpReader + strlen(tmpReader) - 2, "%02X", j);
- (void)strlcpy((sReadersContexts[dwContextB])->lpcLibrary, lpcLibrary,
- sizeof((sReadersContexts[dwContextB])->lpcLibrary));
+ sReadersContexts[dwContextB]->lpcLibrary =
+ sReadersContexts[dwContext]->lpcLibrary;
(void)strlcpy((sReadersContexts[dwContextB])->lpcDevice, lpcDevice,
sizeof((sReadersContexts[dwContextB])->lpcDevice));
(sReadersContexts[dwContextB])->dwVersion =
@@ -477,10 +468,12 @@
return SCARD_E_INVALID_VALUE;
}
+ /* free shared resources when the last slot is closed */
if (*sContext->pdwMutex == 1)
{
(void)SYS_MutexDestroy(sContext->mMutex);
free(sContext->mMutex);
+ free(sContext->lpcLibrary);
}
*sContext->pdwMutex -= 1;
Modified: trunk/PCSC/src/readerfactory.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.h?rev=4723&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.h (original)
+++ trunk/PCSC/src/readerfactory.h Tue Feb 9 10:36:33 2010
@@ -106,7 +106,7 @@
struct ReaderContext
{
char lpcReader[MAX_READERNAME]; /**< Reader Name */
- char lpcLibrary[MAX_LIBNAME]; /**< Library Path */
+ char *lpcLibrary; /**< Library Path */
char lpcDevice[MAX_DEVICENAME]; /**< Device Name */
PCSCLITE_THREAD_T pthThread; /**< Event polling thread */
RESPONSECODE (*pthCardEvent)(DWORD); /**< Card Event sync */
More information about the Pcsclite-cvs-commit
mailing list