commit fc3d35d: [Minor] Allow virtual symbols with no parent

Vsevolod Stakhov vsevolod at highsecure.ru
Sat May 18 13:42:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-05-18 14:19:24 +0100
URL: https://github.com/rspamd/rspamd/commit/fc3d35d4faa1572d5f92b7b08532ed42feb7176a

[Minor] Allow virtual symbols with no parent

---
 src/libserver/rspamd_symcache.c |  5 +----
 src/lua/lua_config.c            | 11 +++++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c
index c36a7e1d7..1d285dc6f 100644
--- a/src/libserver/rspamd_symcache.c
+++ b/src/libserver/rspamd_symcache.c
@@ -886,7 +886,7 @@ rspamd_symcache_add_symbol (struct rspamd_symcache *cache,
 	if (name == NULL && !(type & SYMBOL_TYPE_CALLBACK)) {
 		msg_warn_cache ("no name for non-callback symbol!");
 	}
-	else if ((type & SYMBOL_TYPE_VIRTUAL) && parent == -1) {
+	else if ((type & SYMBOL_TYPE_VIRTUAL & (~SYMBOL_TYPE_GHOST)) && parent == -1) {
 		msg_warn_cache ("no parent symbol is associated with virtual symbol %s",
 			name);
 	}
@@ -976,9 +976,6 @@ rspamd_symcache_add_symbol (struct rspamd_symcache *cache,
 			item->specific.normal.condition_cb = -1;
 		}
 		else {
-			/* Require parent */
-			g_assert (parent != -1);
-
 			item->is_virtual = TRUE;
 			item->specific.virtual.parent = parent;
 			item->id = cache->virtual->len;
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index f78a8f452..a60ad8493 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1683,10 +1683,10 @@ lua_config_get_key (lua_State *L)
 	return 1;
 }
 
-static gint
+static guint
 lua_parse_symbol_flags (const gchar *str)
 {
-	int ret = 0;
+	guint ret = 0;
 
 	if (str) {
 		if (strstr (str, "fine") != NULL) {
@@ -1713,6 +1713,9 @@ lua_parse_symbol_flags (const gchar *str)
 		if (strstr (str, "trivial") != NULL) {
 			ret |= SYMBOL_TYPE_TRIVIAL;
 		}
+		if (strstr (str, "ghost") != NULL) {
+			ret |= SYMBOL_TYPE_GHOST;
+		}
 		if (strstr (str, "mime") != NULL) {
 			ret |= SYMBOL_TYPE_MIME_ONLY;
 		}
@@ -1730,10 +1733,10 @@ lua_parse_symbol_flags (const gchar *str)
 	return ret;
 }
 
-static gint
+static guint
 lua_parse_symbol_type (const gchar *str)
 {
-	gint ret = SYMBOL_TYPE_NORMAL;
+	guint ret = SYMBOL_TYPE_NORMAL;
 	gchar **vec;
 	guint i, l;
 


More information about the Commits mailing list