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
slot: remove infinite loop when card change happens
When reader is removed and inserted back between two
consecutive calls to PCSC SCardGetStatusChange() function,
and no reconnection is done, the status will remain
SC_READER_CARD_CHANGED.
  • Loading branch information
xhanulik committed Mar 20, 2024
commit b465e94c0911aa341413fcfe44323be3d15d0da8
7 changes: 4 additions & 3 deletions src/pkcs11/slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ CK_RV card_detect(sc_reader_t *reader)
CK_RV rv;
unsigned int i;
int j;
int retry = 3;

sc_log(context, "%s: Detecting smart card", reader->name);
/* Check if someone inserted a card */
Expand All @@ -235,10 +236,10 @@ CK_RV card_detect(sc_reader_t *reader)
sc_log(context, "%s: Card changed", reader->name);
/* The following should never happen - but if it
* does we'll be stuck in an endless loop.
* So better be fussy.
if (!retry--)
return CKR_TOKEN_NOT_PRESENT; */
* So better be fussy.*/
card_removed(reader);
if (!retry--)
return CKR_TOKEN_NOT_PRESENT;
goto again;
}

Expand Down