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.2.29.rc1~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba0aa2d1b71829a760d21e23ec847a479ef08023;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 6867046764..731be0a1d8 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); @@ -144,8 +144,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; @@ -225,8 +225,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; @@ -313,9 +313,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)