]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Always allow error_r to be NULL.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 30 May 2016 18:14:53 +0000 (21:14 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 30 May 2016 18:16:56 +0000 (21:16 +0300)
Especially dcrypt_openssl_private_to_public_key() was called with
error_r=NULL by the dcrypt.c itself.

src/lib-dcrypt/dcrypt-openssl.c

index 60cb0a9de36bab6d58f325250ac58a04018cd2bc..b477a1baee4a9a50745fcb0da35d2348662865d5 100644 (file)
@@ -385,7 +385,8 @@ bool dcrypt_openssl_ctx_hmac_create(const char *algorithm, struct dcrypt_context
        const EVP_MD *md;
        md = EVP_get_digestbyname(algorithm);
        if(md == NULL) {
-               *error_r = t_strdup_printf("Invalid digest %s", algorithm);
+               if (error_r != NULL)
+                       *error_r = t_strdup_printf("Invalid digest %s", algorithm);
                return FALSE;
        }
        /* allocate context */
@@ -673,7 +674,8 @@ bool dcrypt_openssl_pbkdf2(const unsigned char *password, size_t password_len, c
                /* determine MD */
                const EVP_MD* md = EVP_get_digestbyname(hash);
                if (md == NULL) {
-                       *error_r = t_strdup_printf("Invalid digest %s", hash);
+                       if (error_r != NULL)
+                               *error_r = t_strdup_printf("Invalid digest %s", hash);
                        return FALSE;
                }
 
@@ -1550,7 +1552,8 @@ bool dcrypt_openssl_store_private_key(struct dcrypt_private_key *key, enum dcryp
        if (cipher != NULL) {
                algo = EVP_get_cipherbyname(cipher);
                if (algo == NULL) {
-                       *error_r = t_strdup_printf("Invalid cipher %s", cipher);
+                       if (error_r != NULL)
+                               *error_r = t_strdup_printf("Invalid cipher %s", cipher);
                        return FALSE;
                }
        }
@@ -1630,7 +1633,8 @@ bool dcrypt_openssl_private_to_public_key(struct dcrypt_private_key *priv_key, s
                EVP_PKEY_set1_EC_KEY(pk, eck);
                EC_KEY_free(eck);
        } else {
-               *error_r = "Invalid private key";
+               if (error_r != NULL)
+                       *error_r = "Invalid private key";
                return FALSE;
        }