]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Push flag and value for fuzzy pre scripts
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 18 Jan 2025 13:32:45 +0000 (13:32 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 18 Jan 2025 13:33:08 +0000 (13:33 +0000)
src/fuzzy_storage.c

index 270dd9c539757643e21f7e9844c2c27dbf3406df..ca7f195b6477e65d0bfec18bee925ca957dba2e6 100644 (file)
@@ -1305,7 +1305,7 @@ rspamd_fuzzy_check_callback(struct rspamd_fuzzy_reply *result, void *ud)
                        lua_pushcfunction(L, &rspamd_lua_traceback);
                        err_idx = lua_gettop(L);
                        /* Preallocate stack (small opt) */
-                       lua_checkstack(L, err_idx + 9);
+                       lua_checkstack(L, err_idx + nargs + 9);
                        /* function */
                        lua_rawgeti(L, LUA_REGISTRYINDEX, cur->cbref);
                        /* client IP */
@@ -1500,12 +1500,12 @@ rspamd_fuzzy_process_command(struct fuzzy_session *session)
                {
                        /* Start lua pre handler */
                        lua_State *L = session->ctx->cfg->lua_state;
-                       int err_idx, ret, nargs = 5;
+                       int err_idx, ret, nargs = 7;
 
                        lua_pushcfunction(L, &rspamd_lua_traceback);
                        err_idx = lua_gettop(L);
                        /* Preallocate stack (small opt) */
-                       lua_checkstack(L, err_idx + 5);
+                       lua_checkstack(L, err_idx + nargs + 1);
                        /* function */
                        lua_rawgeti(L, LUA_REGISTRYINDEX, cur->cbref);
                        /* client IP */
@@ -1525,6 +1525,10 @@ rspamd_fuzzy_process_command(struct fuzzy_session *session)
                                nargs++;
                        }
 
+                       /* Flag and value */
+                       lua_pushinteger(L, cmd->flag);
+                       lua_pushinteger(L, cmd->value);
+
                        if ((ret = lua_pcall(L, nargs, LUA_MULTRET, err_idx)) != 0) {
                                msg_err("call to lua_pre_handler lua "
                                                "script failed (%d): %s",