diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-21 16:01:46 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-21 16:01:46 +0100 |
commit | 10c1e15350a190560eb5b281779d68cbc099bc68 (patch) | |
tree | fd9609e1eed00fda4dd8f98be37c34735e1c9258 /src | |
parent | ee7bbf1c3d84d61e75504608b4b489cc1cc3afee (diff) | |
download | rspamd-10c1e15350a190560eb5b281779d68cbc099bc68.tar.gz rspamd-10c1e15350a190560eb5b281779d68cbc099bc68.zip |
[Fix] Do not use strdup on data extracted from lua
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/re_cache.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 88e346cc5..a9fc2270b 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -855,12 +855,15 @@ rspamd_re_cache_process_selector (struct rspamd_task *task, } else { gsize slen; + const gchar *sel_data; if (lua_type (L, -1) == LUA_TSTRING) { + sel_data = lua_tolstring (L, -1, &slen); *n = 1; *svec = g_malloc (sizeof (guchar *)); *lenvec = g_malloc (sizeof (guint)); - (*svec)[0] = g_strdup (lua_tolstring (L, -1, &slen)); + (*svec)[0] = g_malloc (slen); + memcpy ((*svec)[0], sel_data, slen); (*lenvec)[0] = slen; result = TRUE; @@ -874,7 +877,10 @@ rspamd_re_cache_process_selector (struct rspamd_task *task, for (guint i = 0; i < *n; i ++) { lua_rawgeti (L, -1, i + 1); - (*svec)[i] = g_strdup (lua_tolstring (L, -1, &slen)); + + sel_data = lua_tolstring (L, -1, &slen); + (*svec)[i] = g_malloc (slen); + memcpy ((*svec)[i], sel_data, slen); (*lenvec)[i] = slen; lua_pop (L, 1); } |