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

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Thu Nov 6 14:57:11 UTC 2014


Author: rousseau
Date: 2014-11-06 14:57:11 +0000 (Thu, 06 Nov 2014)
New Revision: 7029

Modified:
   trunk/PCSC/src/hotplug_libusb.c
Log:
Do not access pipefd[] after use

It is NOT safe to pass to a thread a pointer to a locally allocated array.
When the caller exits the scope of the array then the memory is reused.
So any reference to the array becomes illegal memory access.

Thanks to Maximilian Stein for the patch
http://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20141103/000218.html


Modified: trunk/PCSC/src/hotplug_libusb.c
===================================================================
--- trunk/PCSC/src/hotplug_libusb.c	2014-11-06 14:24:02 UTC (rev 7028)
+++ trunk/PCSC/src/hotplug_libusb.c	2014-11-06 14:57:11 UTC (rev 7029)
@@ -432,7 +432,6 @@
 
 	/* signal that the initially connected readers are now visible */
 	write(pipefd[1], &c, 1);
-	close(pipefd[1]);
 
 	/* if at least one driver do not have IFD_GENERATE_HOTPLUG */
 	do_polling = FALSE;
@@ -509,7 +508,10 @@
 
 		/* Wait for initial readers to setup */
 		read(pipefd[0], &c, 1);
+
+		/* cleanup pipe fd */
 		close(pipefd[0]);
+		close(pipefd[1]);
 	}
 
 	return 0;




More information about the Pcsclite-cvs-commit mailing list