]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
var-expand-crypt: Do not bail out early in var_expand_crypt_settings()
authorAki Tuomi <aki.tuomi@open-xchange.com>
Sun, 17 Nov 2024 11:35:43 +0000 (13:35 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:01 +0000 (10:40 +0200)
Simplifies next change.

src/plugins/var-expand-crypt/var-expand-crypt-plugin.c

index 852b9c43840d842ff75878f0265c521b9708c406..d90ed7ddde293a6fba4cfc98151e7c2534d5bbe6 100644 (file)
@@ -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;