[Pcsclite-cvs-commit] r3446 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Apr 14 09:24:48 UTC 2009
Author: rousseau
Date: Tue Apr 14 09:24:47 2009
New Revision: 3446
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3446
Log:
WaitForPcscdEvent(): avoid a possible crash due to a race condition
Thanks to Matheus Ribeiro for the patch
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=3446&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Apr 14 09:24:47 2009
@@ -1743,13 +1743,18 @@
(void)mkfifo(filename, 0644);
fd = SYS_OpenFile(filename, O_RDONLY | O_NONBLOCK, 0);
- FD_ZERO(&read_fd);
- FD_SET(fd, &read_fd);
-
- (void)select(fd+1, &read_fd, NULL, NULL, ptv);
-
- (void)SYS_ReadFile(fd, buf, 1);
- (void)SYS_CloseFile(fd);
+ /* the file may have been removed between the mkfifo() and open() */
+ if (-1 != fd)
+ {
+ FD_ZERO(&read_fd);
+ FD_SET(fd, &read_fd);
+
+ (void)select(fd+1, &read_fd, NULL, NULL, ptv);
+
+ (void)SYS_ReadFile(fd, buf, 1);
+ (void)SYS_CloseFile(fd);
+ }
+
(void)SYS_RemoveFile(filename);
if (INFINITE != dwTime)
More information about the Pcsclite-cvs-commit
mailing list