[pkg-opensc-commit] [engine-pkcs11] 34/152: allow hex characters as well, patch supplied by Alexander Starostin <assur at esc.ru>
Eric Dorland
eric at moszumanska.debian.org
Mon Oct 19 03:11:11 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 70b8680755fad25cd44e2ccd1b83421903af0959
Author: Nils Larsch <nlarsch at gmx.net>
Date: Mon Sep 18 05:04:49 2006 +0000
allow hex characters as well, patch supplied by Alexander Starostin <assur at esc.ru>
---
src/engine_pkcs11.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/engine_pkcs11.c b/src/engine_pkcs11.c
index 987d318..3ba212e 100644
--- a/src/engine_pkcs11.c
+++ b/src/engine_pkcs11.c
@@ -220,9 +220,12 @@ int parse_slot_id_string(const char *slot_id, int *slot,
return 0;
/* support for several formats */
+#define HEXDIGITS "01234567890ABCDEFabcdef"
+#define DIGITS "0123456789"
+
/* first: pure hex number (id, slot is 0) */
- if (strspn(slot_id,"01234567890ABCDEFabcdef") == strlen(slot_id)) {
+ 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");
@@ -234,7 +237,7 @@ int parse_slot_id_string(const char *slot_id, int *slot,
/* second: slot:id. slot is an digital int. */
if (sscanf(slot_id,"%d",&n) == 1) {
- i = strspn(slot_id,"0123456789");
+ i = strspn(slot_id,DIGITS);
if (slot_id[i] != ':') {
fprintf(stderr,"could not parse string!\n");
@@ -246,7 +249,7 @@ int parse_slot_id_string(const char *slot_id, int *slot,
*id_len = 0;
return 1;
}
- if (strspn(slot_id+i,"0123456789")+i != strlen(slot_id)) {
+ if (strspn(slot_id+i,HEXDIGITS)+i != strlen(slot_id)) {
fprintf(stderr,"could not parse string!\n");
return 0;
}
@@ -261,7 +264,7 @@ int parse_slot_id_string(const char *slot_id, int *slot,
/* third: id_<id> */
if ( strncmp(slot_id, "id_",3) == 0) {
- if (strspn(slot_id+3,"0123456789")+3 != strlen(slot_id)) {
+ if (strspn(slot_id+3,HEXDIGITS)+3 != strlen(slot_id)) {
fprintf(stderr,"could not parse string!\n");
return 0;
}
@@ -287,7 +290,7 @@ int parse_slot_id_string(const char *slot_id, int *slot,
return 0;
}
- i = strspn(slot_id+5,"0123456789");
+ i = strspn(slot_id+5,DIGITS);
if (slot_id[i+5] == 0) {
*slot = n;
@@ -304,7 +307,7 @@ int parse_slot_id_string(const char *slot_id, int *slot,
/* now followed by "id_" */
if ( strncmp(slot_id+i, "id_",3) == 0) {
- if (strspn(slot_id+i+3,"0123456789")+3+i != strlen(slot_id)) {
+ if (strspn(slot_id+i+3,HEXDIGITS)+3+i != strlen(slot_id)) {
fprintf(stderr,"could not parse string!\n");
return 0;
}
--
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