aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/backends
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-05-24 14:13:13 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-05-24 14:13:13 +0100
commiteb5fc65aca905ad38bab0dae85dba0f9a56d7766 (patch)
tree126bf68a7c23e471920f73951ad8cd2326237a5b /src/libstat/backends
parent8303b194152ffc02b5079b6bd08f1fecfd43f5d0 (diff)
downloadrspamd-eb5fc65aca905ad38bab0dae85dba0f9a56d7766.tar.gz
rspamd-eb5fc65aca905ad38bab0dae85dba0f9a56d7766.zip
[Fix] Do not use lightuserdata for traceback
LuaJIT limits lightuserdata usage to 47 bits. On Arm64, this leads to break of the C <-> Lua interoperability using this type. This rework has changed traceback function behaviour from lightuserdata opaque pointer (GString * in particular) to luaL_Buffer. Issue: #2906
Diffstat (limited to 'src/libstat/backends')
-rw-r--r--src/libstat/backends/redis_backend.c8
-rw-r--r--src/libstat/backends/sqlite3_backend.c16
2 files changed, 9 insertions, 15 deletions
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index d54767c12..5976968a7 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -148,7 +148,6 @@ rspamd_redis_expand_object (const gchar *pattern,
struct rspamd_statfile_config *stcf;
lua_State *L = NULL;
struct rspamd_task **ptask;
- GString *tb;
const gchar *rcpt = NULL;
gint err_idx;
@@ -172,16 +171,15 @@ rspamd_redis_expand_object (const gchar *pattern,
rspamd_lua_setclass (L, "rspamd{task}", -1);
if (lua_pcall (L, 1, 1, err_idx) != 0) {
- tb = lua_touserdata (L, -1);
- msg_err_task ("call to user extraction script failed: %v", tb);
- g_string_free (tb, TRUE);
+ msg_err_task ("call to user extraction script failed: %s",
+ lua_tostring (L, -1));
}
else {
rcpt = rspamd_mempool_strdup (task->task_pool, lua_tostring (L, -1));
}
/* Result + error function */
- lua_pop (L, 2);
+ lua_settop (L, err_idx - 1);
}
if (rcpt) {
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c
index cf7291ee0..61bc5bbd3 100644
--- a/src/libstat/backends/sqlite3_backend.c
+++ b/src/libstat/backends/sqlite3_backend.c
@@ -314,7 +314,6 @@ rspamd_sqlite3_get_user (struct rspamd_stat_sqlite3_db *db,
const gchar *user = NULL;
struct rspamd_task **ptask;
lua_State *L = db->L;
- GString *tb;
if (db->cbref_user == -1) {
user = rspamd_task_get_principal_recipient (task);
@@ -330,16 +329,15 @@ rspamd_sqlite3_get_user (struct rspamd_stat_sqlite3_db *db,
rspamd_lua_setclass (L, "rspamd{task}", -1);
if (lua_pcall (L, 1, 1, err_idx) != 0) {
- tb = lua_touserdata (L, -1);
- msg_err_task ("call to user extraction script failed: %v", tb);
- g_string_free (tb, TRUE);
+ msg_err_task ("call to user extraction script failed: %s",
+ lua_tostring (L, -1));
}
else {
user = rspamd_mempool_strdup (task->task_pool, lua_tostring (L, -1));
}
/* Result + error function */
- lua_pop (L, 2);
+ lua_settop (L, err_idx - 1);
}
@@ -377,7 +375,6 @@ rspamd_sqlite3_get_language (struct rspamd_stat_sqlite3_db *db,
struct rspamd_mime_text_part *tp;
struct rspamd_task **ptask;
lua_State *L = db->L;
- GString *tb;
if (db->cbref_language == -1) {
for (i = 0; i < task->text_parts->len; i++) {
@@ -401,9 +398,8 @@ rspamd_sqlite3_get_language (struct rspamd_stat_sqlite3_db *db,
rspamd_lua_setclass (L, "rspamd{task}", -1);
if (lua_pcall (L, 1, 1, err_idx) != 0) {
- tb = lua_touserdata (L, -1);
- msg_err_task ("call to language extraction script failed: %v", tb);
- g_string_free (tb, TRUE);
+ msg_err_task ("call to language extraction script failed: %s",
+ lua_tostring (L, -1));
}
else {
language = rspamd_mempool_strdup (task->task_pool,
@@ -411,7 +407,7 @@ rspamd_sqlite3_get_language (struct rspamd_stat_sqlite3_db *db,
}
/* Result + error function */
- lua_pop (L, 2);
+ lua_settop (L, err_idx - 1);
}