Skip to content

Commit

Permalink
Remove space padding from slot and token info
Browse files Browse the repository at this point in the history
Otherwise the strncmp() matching against pksc11 URI fails.
  • Loading branch information
fabled committed Nov 24, 2022
1 parent 62e2f9e commit 70c0ea4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,15 @@ static void get_slot_mechanisms(P11PROV_CTX *ctx, struct p11prov_slot *slot)
P11PROV_debug("Slot(%lu) mechs found: %lu", slot->id, slot->mechs_num);
}

static void trim_padded_field(CK_UTF8CHAR *field, ssize_t n)
{
for (; n > 0 && field[n - 1] == ' '; n--) {
field[n - 1] = 0;
}
}

#define trim(x) trim_padded_field(x, sizeof(x))

static CK_RV get_slots(P11PROV_CTX *ctx)
{
CK_ULONG nslots;
Expand Down Expand Up @@ -1075,6 +1084,13 @@ static CK_RV get_slots(P11PROV_CTX *ctx)
goto done;
}

trim(slots[i].slot.slotDescription);
trim(slots[i].slot.manufacturerID);
trim(slots[i].token.label);
trim(slots[i].token.manufacturerID);
trim(slots[i].token.model);
trim(slots[i].token.serialNumber);

ret = p11prov_session_pool_init(ctx, &slots[i].token, &(slots[i].pool));
if (ret) {
goto done;
Expand Down

0 comments on commit 70c0ea4

Please sign in to comment.