[Pcsclite-cvs-commit] r6354 - /trunk/PCSC/src/readerfactory.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Mon Jun 25 13:17:33 UTC 2012
Author: rousseau
Date: Mon Jun 25 13:17:33 2012
New Revision: 6354
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6354
Log:
RFAddReader(): truncates the reader name if too long
The reader name size is limited to a total of MAX_READERNAME characters
(100 by default). But some reader names are very long like:
"SCM Microsystems Inc. SCR3340 - ExpressCard54 Smart Card Reader" and
also provide a serial number and an interface name. So the name
constructed by hotplug_libudev.c can be very long and longer than the
100 caracters.
Closes: [#313684] "Reader name too long" error
https://alioth.debian.org/tracker/?func=detail&atid=410085&aid=313684&group_id=30105
http://archives.neohapsis.com/archives/dev/muscle/2012-q2/0113.html
Modified:
trunk/PCSC/src/readerfactory.c
Modified: trunk/PCSC/src/readerfactory.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.c?rev=6354&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.c (original)
+++ trunk/PCSC/src/readerfactory.c Mon Jun 25 13:17:33 2012
@@ -106,7 +106,7 @@
return EHInitializeEventStructures();
}
-LONG RFAddReader(const char *readerName, int port, const char *library,
+LONG RFAddReader(const char *readerNameLong, int port, const char *library,
const char *device)
{
DWORD dwContext = 0, dwGetSize;
@@ -114,17 +114,22 @@
LONG rv, parentNode;
int i, j;
int lrv = 0;
-
- if ((readerName == NULL) || (library == NULL) || (device == NULL))
+ char *readerName = NULL;
+
+ if ((readerNameLong == NULL) || (library == NULL) || (device == NULL))
return SCARD_E_INVALID_VALUE;
+
+ /* allocate memory that is automatically freed */
+ readerName = alloca(strlen(readerNameLong));
+ strcpy(readerName, readerNameLong);
/* Reader name too long? also count " 00 00"*/
if (strlen(readerName) > MAX_READERNAME - sizeof(" 00 00"))
{
Log3(PCSC_LOG_ERROR,
- "Reader name too long: %zd chars instead of max %zd",
+ "Reader name too long: %zd chars instead of max %zd. Truncating!",
strlen(readerName), MAX_READERNAME - sizeof(" 00 00"));
- return SCARD_E_INVALID_VALUE;
+ readerName[MAX_READERNAME - sizeof(" 00 00")] = '\0';
}
/* Same name, same port - duplicate reader cannot be used */
More information about the Pcsclite-cvs-commit
mailing list