From: Aki Tuomi Date: Mon, 27 Mar 2017 06:39:03 +0000 (+0300) Subject: var-expand-crypt: Add error handling for initialization X-Git-Tag: 2.3.0.rc1~1831 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d2c15eaba4920cb6556be2c735fdb3f79655aba;p=thirdparty%2Fdovecot%2Fcore.git var-expand-crypt: Add error handling for initialization --- diff --git a/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c b/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c index 251a1455c4..b67def0168 100644 --- a/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c +++ b/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c @@ -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)