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 relation between reader and slot
The card_detect() can detect removed reader,
it calls card_removed(), but card_detect_all()
did not remove relation between slot and reader.
  • Loading branch information
xhanulik committed Mar 20, 2024
commit 668ddda8651be1c09c67ffcd877e1b75dd9d10a7
11 changes: 11 additions & 0 deletions src/pkcs11/slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,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);
Copy link
Member

Choose a reason for hiding this comment

The 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");
Expand Down