]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail-lua: lua_call and lua_file var_expand filters - check for missing parameters
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 16 Jan 2025 11:39:07 +0000 (13:39 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:02 +0000 (10:40 +0200)
src/plugins/mail-lua/mail-lua-plugin.c

index 8bc73f02fcc20414df231fcf87c79ed009fdde55..9f10e2ad45c2a2efaa828426aa690d951ad4f07c 100644 (file)
@@ -270,8 +270,8 @@ static int mail_lua_var_expand_lua_file(const struct var_expand_statement *stmt,
                                        struct var_expand_state *state,
                                        const char **error_r)
 {
-       const char *file;
-       const char *fn;
+       const char *file = NULL;
+       const char *fn = NULL;
        const char *value;
 
        ARRAY_TYPE(const_string) params;
@@ -302,6 +302,11 @@ static int mail_lua_var_expand_lua_file(const struct var_expand_statement *stmt,
                }
        }
 
+       if (file == NULL || fn == NULL) {
+               *error_r = "Missing parameters";
+               return -1;
+       }
+
        struct dlua_script *script;
        if (mail_lua_script_load(file, &script, error_r) < 0)
                return -1;
@@ -316,7 +321,7 @@ static int mail_lua_var_expand_lua_call(const struct var_expand_statement *stmt,
                                        struct var_expand_state *state,
                                        const char **error_r)
 {
-       const char *fn;
+       const char *fn = NULL;
        const char *value;
 
        ARRAY_TYPE(const_string) params;
@@ -341,6 +346,11 @@ static int mail_lua_var_expand_lua_call(const struct var_expand_statement *stmt,
                }
        }
 
+       if (fn == NULL) {
+               *error_r = "Missing parameters";
+               return -1;
+       }
+
        if (state->params->event == NULL) {
                *error_r = "No mail user available";
                return -1;