aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-08-20 18:52:03 +0100
committerGitHub <noreply@github.com>2021-08-20 18:52:03 +0100
commit21a214f3dada7e206b8c494eb64c146d411d0f47 (patch)
tree9d03a82718d9e018b79991e46835ffaa6b552571
parent4fc136a7f8d278a7da7e8e53b417379b24ccb7c6 (diff)
parentcdedeb9f4f3168293a1efe0347da753b6f812a5e (diff)
downloadrspamd-21a214f3dada7e206b8c494eb64c146d411d0f47.tar.gz
rspamd-21a214f3dada7e206b8c494eb64c146d411d0f47.zip
Merge pull request #3852 from tomop-tg/lua54
fix compatibility with lua-5.4
-rw-r--r--src/libserver/cfg_rcl.c3
-rw-r--r--src/libstat/stat_config.c3
-rw-r--r--src/lua/lua_thread_pool.cxx5
-rw-r--r--src/plugins/fuzzy_check.c3
-rw-r--r--src/plugins/lua/hfilter.lua4
-rw-r--r--src/plugins/lua/milter_headers.lua2
6 files changed, 16 insertions, 4 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index b19a1dedc..d91ebf3ae 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -3571,6 +3571,9 @@ rspamd_rcl_maybe_apply_lua_transform (struct rspamd_config *cfg)
return;
}
else {
+#if LUA_VERSION_NUM >= 504
+ lua_settop(L, -2);
+#endif
if (lua_type (L, -1) != LUA_TFUNCTION) {
msg_warn_config ("lua script must return "
"function and not %s",
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 17d0fdcc7..0c9ae2ed0 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -172,6 +172,9 @@ rspamd_stat_init (struct rspamd_config *cfg, struct ev_loop *ev_base)
lua_tostring (L, -1));
}
else {
+#if LUA_VERSION_NUM >= 504
+ lua_settop(L, -2);
+#endif
if (lua_type (L, -1) != LUA_TTABLE) {
msg_err_config ("lua stat must return "
"table and not %s",
diff --git a/src/lua/lua_thread_pool.cxx b/src/lua/lua_thread_pool.cxx
index 62da49482..dc6c15163 100644
--- a/src/lua/lua_thread_pool.cxx
+++ b/src/lua/lua_thread_pool.cxx
@@ -261,12 +261,15 @@ lua_thread_pool_restore_callback_full(struct lua_callback_state *cbs,
static gint
lua_do_resume_full(lua_State *L, gint narg, const gchar *loc) {
+#if LUA_VERSION_NUM >= 504
+ int nres;
+#endif
msg_debug_lua_threads ("%s: lua_do_resume_full", loc);
#if LUA_VERSION_NUM < 502
return lua_resume(L, narg);
#else
#if LUA_VERSION_NUM >= 504
- return lua_resume (L, NULL, narg, NULL);
+ return lua_resume (L, NULL, narg, &nres);
#else
return lua_resume (L, NULL, narg);
#endif
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 722daeacb..ea8bcf756 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -1006,6 +1006,9 @@ fuzzy_check_module_config (struct rspamd_config *cfg, bool validate)
fuzzy_module_ctx->enabled = FALSE;
}
else {
+#if LUA_VERSION_NUM >= 504
+ lua_settop(L, -2);
+#endif
if (lua_type (L, -1) != LUA_TTABLE) {
msg_err_config ("lua fuzzy must return "
"table and not %s",
diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua
index 9179f63b8..3889eaa5b 100644
--- a/src/plugins/lua/hfilter.lua
+++ b/src/plugins/lua/hfilter.lua
@@ -357,7 +357,7 @@ local function hfilter_callback(task)
local lines = html_text_part:get_lines_count()
if lines > 0 and lines < 2 then
task:insert_result('HFILTER_URL_ONELINE', 1.00,
- string.format('html:%d:%d', sc, lines))
+ string.format('html:%d:%d', math.floor(sc), lines))
end
end
end
@@ -376,7 +376,7 @@ local function hfilter_callback(task)
local lines = plain_text_part:get_lines_count()
if lines > 0 and lines < 2 then
task:insert_result('HFILTER_URL_ONELINE', 1.00,
- string.format('plain:%d:%d', rel, lines))
+ string.format('plain:%d:%d', math.floor(rel), lines))
end
end
end
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index 0dfaa9e03..1b58cee86 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -383,7 +383,7 @@ local function milter_headers(task)
if local_mod.remove then
remove[local_mod.header] = local_mod.remove
end
- add[local_mod.header] = string.rep(local_mod.char, score)
+ add[local_mod.header] = string.rep(local_mod.char, math.floor(score))
end
local function spam_header (class, name, value, remove_v)