From: Aki Tuomi Date: Mon, 27 Mar 2017 08:02:31 +0000 (+0300) Subject: var-expand-crypt: Fix data decryption X-Git-Tag: 2.2.29.rc1~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb8b63efcd303af12e86341ebf7612c0c3f4bf91;p=thirdparty%2Fdovecot%2Fcore.git var-expand-crypt: Fix data decryption --- 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 731be0a1d8..812ea3a6f8 100644 --- a/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c +++ b/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c @@ -260,18 +260,14 @@ var_expand_decrypt(struct var_expand_context *_ctx, if (var_expand_crypt_settings(&ctx, args, error_r) < 0) return -1; - str_append(field_value, value); - - const char *encdata = str_c(field_value); - const char *enciv = NULL; + const char *encdata = value; + const char *enciv = ""; /* make sure IV is correct */ if (ctx.iv->used == 0 && (p = strchr(encdata, '$')) != NULL) { /* see if IV can be taken from data */ enciv = t_strcut(encdata, '$'); encdata = t_strcut(p+1,'$'); - } else { - encdata = t_strdup(str_c(field_value)); } str_truncate(field_value, 0); @@ -301,8 +297,10 @@ var_expand_decrypt(struct var_expand_context *_ctx, ret = var_expand_crypt(dctx, ctx.enckey, ctx.iv, field_value, tmp, error_r); dcrypt_ctx_sym_destroy(&dctx); - if (ret == 0) + if (ret == 0) { *result_r = str_c(tmp); + ret = 1; + } return ret; }