File fix-pin-memory-corruption.patch of Package engine_pkcs11

Index: engine_pkcs11-0.1.5/src/engine_pkcs11.c
===================================================================
--- engine_pkcs11-0.1.5.orig/src/engine_pkcs11.c
+++ engine_pkcs11-0.1.5/src/engine_pkcs11.c
@@ -157,7 +157,7 @@ int pkcs11_finish(ENGINE * engine)
 		ctx = NULL;
 	}
 	if (pin != NULL) {
-		OPENSSL_cleanse(pin, MAX_PIN_LENGTH);
+		OPENSSL_cleanse(pin, strlen(pin));
 		free(pin);
 		pin = NULL;
 	}
@@ -181,7 +181,7 @@ int pkcs11_init(ENGINE * engine)
 int pkcs11_rsa_finish(RSA * rsa)
 {
 	if (pin) {
-		OPENSSL_cleanse(pin, MAX_PIN_LENGTH);
+		OPENSSL_cleanse(pin, strlen(pin));
 		free(pin);
 		pin = NULL;
 	}
@@ -685,7 +685,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE
 			/* Free the PIN if it has already been 
 			   assigned (i.e, cached by get_pin) */
 			if (pin != NULL) {
-				OPENSSL_cleanse(pin, MAX_PIN_LENGTH);
+				OPENSSL_cleanse(pin, strlen(pin));
 				free(pin);
 				pin = NULL;
 			}
@@ -695,7 +695,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE
 				fail("Could not allocate memory for PIN");
 			}
 			if (!get_pin(ui_method, callback_data) ) {
-				OPENSSL_cleanse(pin, MAX_PIN_LENGTH);
+				OPENSSL_cleanse(pin, strlen(pin));
 				free(pin);
 				pin = NULL;
 				fail("No pin code was entered");
@@ -706,7 +706,7 @@ static EVP_PKEY *pkcs11_load_key(ENGINE
 		if (PKCS11_login(slot, 0, pin)) {
 			/* Login failed, so free the PIN if present */
 			if (pin != NULL) {
-				OPENSSL_cleanse(pin, MAX_PIN_LENGTH);
+				OPENSSL_cleanse(pin, strlen(pin));
 				free(pin);
 				pin = NULL;
 			}
openSUSE Build Service is sponsored by