[pkg-opensc-commit] [engine-pkcs11] 85/152: Revert some changes to slot parsing code, but add a proper fix instead. (I hope) apply changes by Douglas to print the slot in verbose mode. Create new release and document changes. require latest libp11 with the new function.

Eric Dorland eric at moszumanska.debian.org
Mon Oct 19 03:11:19 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 3fa2bfcfdd1f21eda2c13048c7dde5e7a07d6376
Author: Andreas Jellinghaus <andreas at ionisiert.de>
Date:   Mon Jun 15 19:59:45 2009 +0000

    Revert some changes to slot parsing code, but add a proper fix instead. (I hope)
    apply changes by Douglas to print the slot in verbose mode.
    Create new release and document changes. require latest libp11 with the new
    function.
---
 NEWS                |  6 +++++-
 configure.ac        |  6 +++---
 src/engine_pkcs11.c | 48 +++++++++++++++++++++++++-----------------------
 3 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/NEWS b/NEWS
index ba6335e..4efd186 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,11 @@
 NEWS for Engine PKCS#11 -- History of user visible changes
 
-New in 0.1.6; 2008-??-??; Andreas Jellinghaus
+New in 0.1.6; 2009-06-15; Andreas Jellinghaus
 * Fixed set_pin (strdup causes segfault in OPENSSL_CLEANSE later)
+* Require new libp11 0.2.5 with new function to get the slot id.
+* Revert changes to slot parsing code - seems partial bogus and
+  orginal author doesn't respond to questions.
+* print slot id in verbose mode (Douglas E. Engert).
 
 New in 0.1.5; 2008-07-31; Andreas Jellinghaus
 * Build system rewritten (NOTICE: configure options was modified). 
diff --git a/configure.ac b/configure.ac
index a3bddb9..c70c96c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,8 +3,8 @@ AC_PREREQ(2.60)
 
 define([PACKAGE_VERSION_MAJOR], [0])
 define([PACKAGE_VERSION_MINOR], [1])
-define([PACKAGE_VERSION_FIX], [5])
-define([PACKAGE_SUFFIX], [-svn])
+define([PACKAGE_VERSION_FIX], [6])
+define([PACKAGE_SUFFIX], [])
 
 AC_INIT([engine_pkcs11],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX[]PACKAGE_SUFFIX])
 AC_CONFIG_AUX_DIR([.])
@@ -123,7 +123,7 @@ AC_CHECK_HEADERS([ \
 	locale.h getopt.h dlfcn.h utmp.h \
 ])
 
-PKG_CHECK_MODULES([LIBP11], [libp11 >= 0.2.4],, [AC_MSG_ERROR([libp11 >= 0.2.4 is required])])
+PKG_CHECK_MODULES([LIBP11], [libp11 >= 0.2.5],, [AC_MSG_ERROR([libp11 >= 0.2.5 is required])])
 
 dnl These required for svn checkout
 AC_ARG_VAR([XSLTPROC], [xsltproc utility])
diff --git a/src/engine_pkcs11.c b/src/engine_pkcs11.c
index 37e0cdb..fe60972 100644
--- a/src/engine_pkcs11.c
+++ b/src/engine_pkcs11.c
@@ -331,19 +331,10 @@ static int parse_slot_id_string(const char *slot_id, int *slot,
 
 	i = strspn(slot_id + 5, DIGITS);
 
-        /*
-         * changed 2008-01-28 9:31 GMT by SafeNet UK Ltd, akroehnert at safenet-inc.com
-         * changed comparision from == to >= as we need to check for any slot equal
-         * or greater zero
-         */
-	if (slot_id[i + 5] >= 0) {
+	if (slot_id[i + 5] == 0) {
 		*slot = n;
 		*id_len = 0;
-	/*
-	 * changed 2008-01-28 9:31 GMT by SafeNet UK Ltd, akroehnert at safenet-inc.com
-      * if we jump out here we cant get the label or id parsed
-	 */
-	/*	return 1; */
+		return 1; 
 	}
 
 	if (slot_id[i + 5] != '-') {
@@ -371,10 +362,7 @@ static int parse_slot_id_string(const char *slot_id, int *slot,
 
 	/* ... or "label_" */
 	if (strncmp(slot_id + i, "label_", 6) == 0)
-		/*
-	         * changed 2008-01-28 9:31 CET by SafeNet UK Ltd, akroehnert at safenet-inc.com
-        	 * we have to chop off + i + 6 characters instead of just 6
-		 */
+		*slot = n;
 		return (*label = strdup(slot_id + i + 6)) != NULL;
 
 	fprintf(stderr, "could not parse string!\n");
@@ -389,6 +377,7 @@ static int parse_slot_id_string(const char *slot_id, int *slot,
 static X509 *pkcs11_load_cert(ENGINE * e, const char *s_slot_cert_id)
 {
 	PKCS11_SLOT *slot_list, *slot;
+	PKCS11_SLOT *found_slot = NULL;
 	PKCS11_TOKEN *tok;
 	PKCS11_CERT *certs, *selected_cert = NULL;
 	X509 *x509;
@@ -452,8 +441,14 @@ static X509 *pkcs11_load_cert(ENGINE * e, const char *s_slot_cert_id)
 			flags[m - 2] = '\0';
 		}
 
+		if (slot_nr != -1 &&
+			slot_nr == PKCS11_get_slotid_from_slot(slot)) {
+			found_slot = slot;
+		}
+
 		if (verbose) {
-			fprintf(stderr, "[%u] %-25.25s  %-16s", n,
+			fprintf(stderr, "[%lu] %-25.25s  %-16s",
+				PKCS11_get_slotid_from_slot(slot),
 				slot->description, flags);
 			if (slot->token) {
 				fprintf(stderr, "  (%s)",
@@ -467,9 +462,9 @@ static X509 *pkcs11_load_cert(ENGINE * e, const char *s_slot_cert_id)
 	if (slot_nr == -1) {
 		if (!(slot = PKCS11_find_token(ctx, slot_list, slot_count)))
 			fail("didn't find any tokens\n");
-	} else if (slot_nr >= 0 && slot_nr < slot_count)
-		slot = slot_list + slot_nr;
-	else {
+	} else if (found_slot) {
+		slot = found_slot; 
+	} else {
 		fprintf(stderr, "Invalid slot number: %d\n", slot_nr);
 		PKCS11_release_all_slots(ctx, slot_list, slot_count);
 		return NULL;
@@ -544,6 +539,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
 				 int isPrivate)
 {
 	PKCS11_SLOT *slot_list, *slot;
+	PKCS11_SLOT *found_slot = NULL;
 	PKCS11_TOKEN *tok;
 	PKCS11_KEY *keys, *selected_key = NULL;
 	PKCS11_CERT *certs;
@@ -608,8 +604,14 @@ static EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
 			flags[m - 2] = '\0';
 		}
 
+		if (slot_nr != -1 &&
+			slot_nr == PKCS11_get_slotid_from_slot(slot)) {
+			found_slot = slot;
+		}
+
 		if (verbose) {
-			fprintf(stderr, "[%u] %-25.25s  %-16s", n,
+			fprintf(stderr, "[%lu] %-25.25s  %-16s",
+				PKCS11_get_slotid_from_slot(slot),
 				slot->description, flags);
 			if (slot->token) {
 				fprintf(stderr, "  (%s)",
@@ -623,9 +625,9 @@ static EVP_PKEY *pkcs11_load_key(ENGINE * e, const char *s_slot_key_id,
 	if (slot_nr == -1) {
 		if (!(slot = PKCS11_find_token(ctx, slot_list, slot_count)))
 			fail("didn't find any tokens\n");
-	} else if (slot_nr >= 0 && slot_nr < slot_count)
-		slot = slot_list + slot_nr;
-	else {
+	} else if (found_slot) {
+		slot = found_slot;
+	} else {
 		fprintf(stderr, "Invalid slot number: %d\n", slot_nr);
 		PKCS11_release_all_slots(ctx, slot_list, slot_count);
 		return 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