[Pcsclite-cvs-commit] r1628 - trunk/PCSC/src

Ludovic Rousseau rousseau at costa.debian.org
Wed Aug 31 14:58:20 UTC 2005


Author: rousseau
Date: 2005-08-31 14:58:19 +0000 (Wed, 31 Aug 2005)
New Revision: 1628

Modified:
   trunk/PCSC/src/readerfactory.c
Log:
RFAddReader(): do not silently truncate the reader, library or device
name if they are too long

Thanks to Ribamar Santarosa de Sousa for the bug report


Modified: trunk/PCSC/src/readerfactory.c
===================================================================
--- trunk/PCSC/src/readerfactory.c	2005-08-31 14:48:53 UTC (rev 1627)
+++ trunk/PCSC/src/readerfactory.c	2005-08-31 14:58:19 UTC (rev 1628)
@@ -77,6 +77,30 @@
 	if ((lpcReader == NULL) || (lpcLibrary == NULL) || (lpcDevice == NULL))
 		return SCARD_E_INVALID_VALUE;
 
+	/* Reader name too long? */
+	if (strlen(lpcReader) >= MAX_READERNAME-1)	/* -1 because of \0 */
+	{
+		Log3(PCSC_LOG_ERROR, "Reader name too long: %d chars instead of max %d",
+			strlen(lpcReader), MAX_READERNAME-1);
+		return SCARD_E_INVALID_VALUE;
+	}
+
+	/* Library name too long? */
+	if (strlen(lpcLibrary) >= MAX_LIBNAME-1)	/* -1 because of \0 */
+	{
+		Log3(PCSC_LOG_ERROR, "Library name too long: %d chars instead of max %d",
+			strlen(lpcLibrary), MAX_LIBNAME-1-1);
+		return SCARD_E_INVALID_VALUE;
+	}
+
+	/* Device name too long? */
+	if (strlen(lpcDevice) >= MAX_DEVICENAME-1)	/* -1 because of \0 */
+	{
+		Log3(PCSC_LOG_ERROR, "Device name too long: %d chars instead of max %d",
+			strlen(lpcDevice), MAX_DEVICENAME-1);
+		return SCARD_E_INVALID_VALUE;
+	}
+
 	/*
 	 * Same name, same port - duplicate reader cannot be used 
 	 */




More information about the Pcsclite-cvs-commit mailing list