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

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Tue Sep 9 09:18:06 UTC 2014


Author: rousseau
Date: 2014-09-09 09:18:06 +0000 (Tue, 09 Sep 2014)
New Revision: 6978

Modified:
   trunk/PCSC/src/winscard_msg.c
Log:
Create the libpcsclite/pcscd socket with the SOCK_CLOEXEC flag

The communication socket between libpcsclite and pcscd is created with
the SOCK_CLOEXEC flag added so the socket is automatically closed when
the process (or its childs) calls exec().

The problem happens when an application does exec() without cleaning its
use of libpcsclite using SCardReleaseContext(). I could not reproduce a
real problem but it has been reported on the field with a closed source
application.

Thanks to Stefani Seibold for the bug report and patch.


Modified: trunk/PCSC/src/winscard_msg.c
===================================================================
--- trunk/PCSC/src/winscard_msg.c	2014-09-04 11:36:54 UTC (rev 6977)
+++ trunk/PCSC/src/winscard_msg.c	2014-09-09 09:18:06 UTC (rev 6978)
@@ -81,6 +81,10 @@
 
 /* functions used by libpcsclite only */
 
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
+
 char *getSocketName(void)
 {
 	static char socketName[sizeof(struct sockaddr_un)];
@@ -119,7 +123,7 @@
 	int ret;
 	char *socketName;
 
-	ret = socket(PF_UNIX, SOCK_STREAM, 0);
+	ret = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
 	if (ret < 0)
 	{
 		Log2(PCSC_LOG_CRITICAL, "Error: create on client socket: %s",




More information about the Pcsclite-cvs-commit mailing list