commit b7bc313: [Minor] Add wipe flag for rspamd_text lua object

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Apr 26 15:49:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-04-26 14:03:19 +0100
URL: https://github.com/rspamd/rspamd/commit/b7bc313a9db19a9ef13d841483715ad316670006

[Minor] Add wipe flag for rspamd_text lua object

---
 src/lua/lua_common.h | 5 +++--
 src/lua/lua_task.c   | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

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);
 			}


More information about the Commits mailing list