]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
var-expand-crypt: Add error handling for initialization
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 27 Mar 2017 06:39:03 +0000 (09:39 +0300)
committerGitLab <gitlab@git.dovecot.net>
Thu, 30 Mar 2017 17:48:59 +0000 (20:48 +0300)
src/plugins/var-expand-crypt/var-expand-crypt-plugin.c

index 251a1455c460564f0fed837c8582d25f56acb6ce..b67def0168281fa46444a706856f85d5cc15c7b6 100644 (file)
@@ -28,7 +28,7 @@ struct var_expand_crypt_context {
        bool enc_result_only:1;
 };
 
-static void var_expand_crypt_initialize(void);
+static bool var_expand_crypt_initialize(const char **error_r);
 
 void var_expand_crypt_init(struct module *module);
 void var_expand_crypt_deinit(void);
@@ -141,8 +141,8 @@ var_expand_encrypt(struct var_expand_context *_ctx,
                   const char *key, const char *field,
                   const char **result_r, const char **error_r)
 {
-       if (!has_been_init)
-               var_expand_crypt_initialize();
+       if (!has_been_init && !var_expand_crypt_initialize(error_r))
+               return -1;
 
        const char *p = strchr(key, ';');
        const char *const *args = NULL;
@@ -222,8 +222,8 @@ var_expand_decrypt(struct var_expand_context *_ctx,
                   const char *key, const char *field,
                   const char **result_r, const char **error_r)
 {
-       if (!has_been_init)
-               var_expand_crypt_initialize();
+       if (!has_been_init && !var_expand_crypt_initialize(error_r))
+               return -1;
 
        const char *p = strchr(key, ';');
        const char *const *args = NULL;
@@ -310,9 +310,9 @@ static const struct var_expand_extension_func_table funcs[] = {
        { NULL, NULL, }
 };
 
-static void var_expand_crypt_initialize(void)
+static bool var_expand_crypt_initialize(const char **error_r)
 {
-       dcrypt_initialize(NULL, NULL, NULL);
+       return dcrypt_initialize(NULL, NULL, error_r);
 }
 
 void var_expand_crypt_init(struct module *module ATTR_UNUSED)