From a7524a72bf7fee77bc4bca8cbb39bb21816e3e74 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Sun, 17 Nov 2024 13:35:43 +0200 Subject: [PATCH] var-expand-crypt: Do not bail out early in var_expand_crypt_settings() Simplifies next change. --- .../var-expand-crypt-plugin.c | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) 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 852b9c4384..d90ed7ddde 100644 --- a/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c +++ b/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c @@ -118,22 +118,21 @@ static int var_expand_crypt_settings(struct var_expand_state *state, ERROR_IF_NO_TRANSFER_TO(stmt->function); ctx->input = state->transfer; - if (ctx->raw || strcmp(stmt->function, "encrypt") == 0) - return 0; - - /* handle $ separated input, only support hex */ - const char *const *parts = t_strsplit(str_c(state->transfer), "$"); - if (str_array_length(parts) == 3 && *parts[2] == '\0') { - if (ctx->iv->used > 0) { - *error_r = "Cannot have iv in parameter and input"; + if (!ctx->raw && strcmp(stmt->function, "decrypt") == 0) { + /* handle $ separated input, only support hex */ + const char *const *parts = t_strsplit(str_c(state->transfer), "$"); + if (str_array_length(parts) == 3 && *parts[2] == '\0') { + if (ctx->iv->used > 0) { + *error_r = "Cannot have iv in parameter and input"; + return -1; + } + hex_to_binary(parts[0], ctx->iv); + ctx->input = t_buffer_create(strlen(parts[1]) / 2); + hex_to_binary(parts[1], ctx->input); + } else { + *error_r = "Invalid input format"; return -1; } - hex_to_binary(parts[0], ctx->iv); - ctx->input = t_buffer_create(strlen(parts[1]) / 2); - hex_to_binary(parts[1], ctx->input); - } else { - *error_r = "Invalid input format"; - return -1; } return 0; -- 2.47.3