[Pcsclite-cvs-commit] r5903 - /trunk/Drivers/ccid/src/commands.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Wed Aug 24 08:43:29 UTC 2011


Author: rousseau
Date: Wed Aug 24 08:43:28 2011
New Revision: 5903

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5903
Log:
SetParameters(): use a variable-length array

Use a VLA instead of static size of 65556 to limit stack consumption

Coverity: Event stack_use_local: Local variable "cmd" stack use: 65556
bytes -> 65572 bytes total.
Event stack_use_overflow: The maximum stack use of 32768 bytes is
exceeded.

Modified:
    trunk/Drivers/ccid/src/commands.c

Modified: trunk/Drivers/ccid/src/commands.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/commands.c?rev=5903&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/commands.c (original)
+++ trunk/Drivers/ccid/src/commands.c Wed Aug 24 08:43:28 2011
@@ -2077,7 +2077,7 @@
 RESPONSECODE SetParameters(unsigned int reader_index, char protocol,
 	unsigned int length, unsigned char buffer[])
 {
-	unsigned char cmd[10+CMD_BUF_SIZE];	/* CCID + APDU buffer */
+	unsigned char cmd[10+length];	/* CCID + APDU buffer */
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
 
 	DEBUG_COMM2("length: %d bytes", length);
@@ -2088,10 +2088,6 @@
 	cmd[6] = (*ccid_descriptor->pbSeq)++;
 	cmd[7] = protocol;	/* bProtocolNum */
 	cmd[8] = cmd[9] = 0; /* RFU */
-
-	/* check that the command is not too large */
-	if (length > CMD_BUF_SIZE)
-		return IFD_NOT_SUPPORTED;
 
 	memcpy(cmd+10, buffer, length);
 




More information about the Pcsclite-cvs-commit mailing list