-
Notifications
You must be signed in to change notification settings - Fork 711
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
xhanulik
wants to merge
6
commits into
OpenSC:master
Choose a base branch
from
xhanulik:reader-remove
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
711f5ef
reader-pcsc: Get card status when timeout is received
xhanulik 1125870
reader-pcsc: Set flag denoting change when reader is removed
xhanulik 639fa57
reader-pcsc: remove flag for removed reader
xhanulik b465e94
slot: remove infinite loop when card change happens
xhanulik 668ddda
slot: remove relation between reader and slot
xhanulik d1c5e0d
Check for invalid pcsc card handle before calling SCardStatus
xhanulik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 */ | ||
|
@@ -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; | ||
} | ||
|
||
|
@@ -427,6 +428,17 @@ card_detect_all(void) | |
} | ||
} | ||
card_detect(reader); | ||
|
||
/* If reader was removed, card_removed() was already called in card_detect(), | ||
* remove only relation between reader and slot. */ | ||
if (reader->flags & SC_READER_REMOVED) { | ||
for (j = 0; j<list_size(&virtual_slots); j++) { | ||
sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, j); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are few minor formatting suggests from clang-format, that I would like to bring in too. |
||
if (slot->reader == reader) { | ||
slot->reader = NULL; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
sc_log(context, "All cards detected"); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would probably move these variables into the inner block where you use them.