From: Petr P. <pet...@at...> - 2013-08-30 14:46:01
|
label_<label> allows to search for any token, let's behave the same way with id_<ID> or <ID> too. Without this patch, id_<ID> did not work despite the label_<label> worked. Especially if the only used slot number is different from 0. --- src/engine_pkcs11.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/engine_pkcs11.c b/src/engine_pkcs11.c index 65289a7..42d90e2 100644 --- a/src/engine_pkcs11.c +++ b/src/engine_pkcs11.c @@ -260,14 +260,14 @@ static int parse_slot_id_string(const char *slot_id, int *slot, #define HEXDIGITS "01234567890ABCDEFabcdef:" #define DIGITS "0123456789" - /* first: pure hex number (id, slot is 0) */ + /* first: pure hex number (id, slot is undefined) */ if (strspn(slot_id, HEXDIGITS) == strlen(slot_id)) { /* ah, easiest case: only hex. */ if ((strlen(slot_id) + 1) / 2 > *id_len) { fprintf(stderr, "id string too long!\n"); return 0; } - *slot = 0; + *slot = -1; return hex_to_bin(slot_id, id, id_len); } @@ -298,7 +298,7 @@ static int parse_slot_id_string(const char *slot_id, int *slot, return hex_to_bin(slot_id + i, id, id_len); } - /* third: id_<id> */ + /* third: id_<id>, slot is undefined */ if (strncmp(slot_id, "id_", 3) == 0) { if (strspn(slot_id + 3, HEXDIGITS) + 3 != strlen(slot_id)) { fprintf(stderr, "could not parse string!\n"); @@ -309,12 +309,13 @@ static int parse_slot_id_string(const char *slot_id, int *slot, fprintf(stderr, "id string too long!\n"); return 0; } - *slot = 0; + *slot = -1; return hex_to_bin(slot_id + 3, id, id_len); } - /* label_<label> */ + /* label_<label>, slot is undefined */ if (strncmp(slot_id, "label_", 6) == 0) { + *slot = -1; *label = strdup(slot_id + 6); return *label != NULL; } -- 1.8.1.5 |