From: Vsevolod Stakhov Date: Fri, 26 Apr 2019 13:03:19 +0000 (+0100) Subject: [Minor] Add wipe flag for rspamd_text lua object X-Git-Tag: 1.9.3~68 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b7bc313a9db19a9ef13d841483715ad316670006;p=rspamd.git [Minor] Add wipe flag for rspamd_text lua object --- diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 3157c565e..d9bbff585 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -65,8 +65,9 @@ struct rspamd_lua_ip { rspamd_inet_addr_t *addr; }; -#define RSPAMD_TEXT_FLAG_OWN (1 << 0) -#define RSPAMD_TEXT_FLAG_MMAPED (1 << 1) +#define RSPAMD_TEXT_FLAG_OWN (1u << 0u) +#define RSPAMD_TEXT_FLAG_MMAPED (1u << 1u) +#define RSPAMD_TEXT_FLAG_WIPE (1u << 2u) struct rspamd_lua_text { const gchar *start; guint len; diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 5fe7db556..50e35434c 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -6232,6 +6232,10 @@ lua_text_gc (lua_State *L) if (t != NULL) { if (t->flags & RSPAMD_TEXT_FLAG_OWN) { + if (t->flags & RSPAMD_TEXT_FLAG_WIPE) { + rspamd_explicit_memzero ((guchar *)t->start, t->len); + } + if (t->flags & RSPAMD_TEXT_FLAG_MMAPED) { munmap ((gpointer)t->start, t->len); }