-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
SCardGetStatusChange: Race condition when attaching multiple readers at the same time #190
Comments
Yes, it is a known limitation of One solution would be to use This field is already used by Windows to store the number of readers. I could not find the documentation for that. |
Thank you for your response. IMHO an event count would be better as the number of readers may loose events if a reader is detached and another is attached between two calls of I read your comment |
I may implement the idea I presented. It will only work on GNU/Linux but at least it would be possible to have a "safe" I do not expect Apple or Microsoft to do anything on their own implementation of WinSCard. |
I think I fixed the issue in a beta version. |
Hello @kgraefe |
It's on my list. I could not find the time yet. |
yes it does! thank you 👍 |
Fixed in pcsc-lite 2.3.0. See https://blog.apdu.fr/posts/2024/08/improved-scardgetstatuschange-for-pnpnotification-special-reader/ |
Versions
Platform
Generic USB2.0-CRW [Smart Card Reader Interface] (20070818000000000)
Issue
pcsc_scan -n
and attach a USB hub with two USB card readers attachedI encountered the issue in my own program using
rust-pcsc
but could also reproduce withpcsc_scan
. I think what happens is the following:\\?PnP?\Notification
fires,SCardGetStatusChange
returns. What happens next, depends on when the second reader is enumeratedpcsc_scan
callsSCardListReaders
to get the number of readers. If the second reader is already enumerated, both will be detected.pcsc_scan
callsSCardListReaders
with the buffer. If the second reader is now enumerated but wasn't before, the call will fail withSCARD_E_INSUFFICIENT_BUFFER
and none will be detected.pcsc_scan
callsSCardListReaders
. If the second reader is now enumerated but wasn't before,\\?PnP?\Notification
does not fire and the second reader will not be detected. Otherwise it will fire at some point and go back to 3. so that both readers are detected.In my own program I can mitigate 4. quite easily. However, how to treat 5.? The only thing I could come up with is polling but the point of
SCardGetStatusChange
is to avoid that.Log
see above
The text was updated successfully, but these errors were encountered: