Skip to content

Commit

Permalink
ykcs11: Increase max slots to 64 and handle overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
qpernil committed Nov 29, 2023
1 parent 68004a3 commit 43da2ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ykcs11/ykcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define YKCS11_MANUFACTURER "Yubico (www.yubico.com)"
#define YKCS11_LIBDESC "PKCS#11 PIV Library (SP-800-73)"

#define YKCS11_MAX_SLOTS 16
#define YKCS11_MAX_SLOTS 64
#define YKCS11_MAX_SESSIONS 16

static ykcs11_slot_t slots[YKCS11_MAX_SLOTS];
Expand Down Expand Up @@ -384,6 +384,10 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetSlotList)(

// Initialize piv_state and increase slot count if this is a new slot
if(slot == slots + n_slots) {
if(n_slots >= YKCS11_MAX_SLOTS) {
DBG("Skipping '%s', already managing %u slots", reader, YKCS11_MAX_SLOTS);
continue;
}
DBG("Initializing slot %td for '%s'", slot-slots, reader);
if((rc = ykpiv_init(&slot->piv_state, verbose)) != YKPIV_OK) {
DBG("Unable to initialize libykpiv: %s", ykpiv_strerror(rc));
Expand Down

0 comments on commit 43da2ee

Please sign in to comment.