-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using 'select' in libpcsclite can be problematic for application opening a large number of file descriptors #51
Labels
Comments
Good remark. |
Do you plan to propose a patch? |
Yeah, I planned to propose a patch but I am not sure when I will have the time for that (probably after the holidays). For now I just wanted to bring the issue to your attention. |
LudovicRousseau
pushed a commit
that referenced
this issue
Nov 8, 2019
From [Pcsclite-muscle] select()-induced crashes (and attached tentative fix) http:https://lists.infradead.org/pipermail/pcsclite-muscle/2019-November/001199.html " Hello all, we tracked down some crashes in Firefox [1] to the use of select() and its related macros in the libpcslite library. Recent versions of glibc added checks to ensure that the values of the file descriptors passed to the FD_SET(), FD_CLR() and FD_ISSET() macros have values lower than the FD_SETSIZE constant. If the file descriptor value is found to be higher than FD_SETSIZE then abort() gets called which is ultimately what we're seeing in Firefox. I have attached a patch that replaces the select() calls with poll() which does not suffer from this problem. Unfortunately I don't have a smartcard reader on hand so I can't test the patch myself. Cheers, Gabriele Svelto [1] select() crashes in libpcslite https://bugzilla.mozilla.org/show_bug.cgi?id=1591876 " Fixes github issue #51 "Using 'select' in libpcsclite can be problematic for application opening a large number of file descriptors #51"
Fixed in 20385ef |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ludovic,
Currently, libpcsclite uses select + non-blocking IO when communicating to the PCSC daemon.
However, select can be used only on file descriptors whose value does not exceed FD_SETSIZE. Quote from Linux man page for select:
More often that not, this undefined behavior will come in the form of a stack corruption.
This means that an application which uses libpcsclite is forced to have no more than FD_SETSIZE (1024) open file descriptors at any given moment. Depending on the use-case this limit can be problematic for the application.
There are other I/O event notification mechanisms which do not have this limitation:
poll, epoll on Linux, kqueue on Mac and BSD, IO completion ports on Windows, etc
Have you considered using any of the above?
The text was updated successfully, but these errors were encountered: