changeset 20294:899b205e1e71

lib-dcrypt: Fixed error handling in dcrypt_key_id_public()
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Jun 2016 15:57:48 +0300
parents b5a75b3c5c5c
children 4f4e9b238ddc
files src/lib-dcrypt/dcrypt-openssl.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dcrypt/dcrypt-openssl.c	Sun Jun 05 15:35:13 2016 +0300
+++ b/src/lib-dcrypt/dcrypt-openssl.c	Sun Jun 05 15:57:48 2016 +0300
@@ -1920,7 +1920,7 @@
 	unsigned char buf[EVP_MD_size(md)];
 	EVP_PKEY *pub = (EVP_PKEY*)key;
 	const char *ptr;
-	int ec;
+	bool res;
 	if (pub == NULL) {
 		if (error_r != NULL)
 			*error_r = "key is NULL";
@@ -1945,10 +1945,10 @@
 	if (EVP_DigestInit_ex(ctx, md, NULL) < 1 ||
 	    EVP_DigestUpdate(ctx, (const unsigned char*)ptr, len) < 1 ||
 	    EVP_DigestFinal_ex(ctx, buf, &hlen) < 1) {
-		ec = dcrypt_openssl_error(error_r);
+		res = dcrypt_openssl_error(error_r);
 	} else {
 		buffer_append(result, buf, hlen);
-		ec = 0;
+		res = TRUE;
 	}
 
 #if SSLEAY_VERSION_NUMBER >= 0x1010000fL
@@ -1958,7 +1958,7 @@
 #endif
 	BIO_vfree(b);
 
-	return ec == 0;
+	return res;
 }
 
 static struct dcrypt_vfs dcrypt_openssl_vfs = {