Skip to content
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

Handle short-lived removals of reader in reader driver for PC/SC #2803

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reader-pcsc: Set flag denoting change when reader is removed
When the removed reader is detected for the first time,
set SC_READER_CARD_CHANGED denoting change. Remove
the flag when the condition is hit again.

Before this change, when reader was removed
the reader->flags in refresh_attributes() was updated
from 0x00000001 (SC_READER_CARD_PRESENT) to 0x00000020
(SC_READER_REMOVED). However, when the reader is still
removed by another call to refresh_attributes(),
the flags remained as 0x00000020 (SC_READER_REMOVED).

Now the flags should change with SC_READER_CARD_CHANGED.
  • Loading branch information
xhanulik committed Mar 20, 2024
commit 11258707b0e2dcc569ac85769dbb8be4f2c38bf2
8 changes: 7 additions & 1 deletion src/libopensc/reader-pcsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,13 @@ static int refresh_attributes(sc_reader_t *reader)
|| rv == (LONG)SCARD_E_NO_READERS_AVAILABLE
xhanulik marked this conversation as resolved.
Show resolved Hide resolved
#endif
|| rv == (LONG)SCARD_E_SERVICE_STOPPED) {
reader->flags &= ~(SC_READER_CARD_PRESENT);
/* Set flag when state changes */
if (reader->flags & SC_READER_REMOVED) {
reader->flags &= ~SC_READER_CARD_CHANGED;
} else {
reader->flags |= SC_READER_CARD_CHANGED;
}
reader->flags &= ~SC_READER_CARD_PRESENT;
reader->flags |= SC_READER_REMOVED;
priv->gpriv->removed_reader = reader;
SC_FUNC_RETURN(reader->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
Expand Down