[pkg-opensc-commit] [engine-pkcs11] 127/152: Find token if no slot was specified
Eric Dorland
eric at moszumanska.debian.org
Mon Oct 19 03:11:25 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository engine-pkcs11.
commit bcd888dc6c1087fd305603fd31f19c08f3e91edb
Author: Petr Písař <petr.pisar at atlas.cz>
Date: Tue Aug 20 14:54:03 2013 +0200
Find token if no slot was specified
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 9d150e7..6e05c7b 100644
--- a/src/engine_pkcs11.c
+++ b/src/engine_pkcs11.c
@@ -275,14 +275,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);
}
@@ -313,7 +313,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");
@@ -324,12 +324,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;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/engine-pkcs11.git
More information about the pkg-opensc-commit
mailing list