[Pcsclite-cvs-commit] r4983 - /trunk/PCSC/src/winscard_clnt.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Mon Jun 7 11:46:46 UTC 2010


Author: rousseau
Date: Mon Jun  7 11:46:29 2010
New Revision: 4983

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4983
Log:
SCardEstablishContext(): if pcscd is stared by libpcsclite then close
all file handles except stdin, stdout and stderr so that pcscd does not
confiscate ressources allocated by the application

Thanks to Thierry Fabre for the bug report

Modified:
    trunk/PCSC/src/winscard_clnt.c

Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=4983&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Mon Jun  7 11:46:29 2010
@@ -430,8 +430,17 @@
 
 			if (0 == pid)
 			{
-				int ret;
+				int ret, i, max;
 				char *param = getenv("PCSCLITE_PCSCD_ARGS");
+
+				/* close all file handles except stdin, stdout and
+				 * stderr so that pcscd does not confiscate ressources
+				 * allocated by the application */
+				max = sysconf(_SC_OPEN_MAX);
+				if (-1 == max)
+					max = 1024;
+				for (i=3; i<max; i++)
+					(void)close(i);
 
 				/* son process */
 				ret = execl(PCSCD_BINARY, "pcscd", "--auto-exit", param,




More information about the Pcsclite-cvs-commit mailing list