]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] More strict boundaries checks and composites policies fix
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 9 Apr 2017 10:01:50 +0000 (11:01 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 9 Apr 2017 10:01:50 +0000 (11:01 +0100)
src/libserver/cfg_rcl.c
src/libserver/html.c
src/libstat/tokenizers/tokenizers.c

index 87b2dd0fa45b9c9dcba07ea7c7d3d9e670527180..1e13f6a567fd0d412574cf252fd3d33bbef95bb6 100644 (file)
@@ -1480,14 +1480,6 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
                rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_composite));
        composite->expr = expr;
        composite->id = g_hash_table_size (cfg->composite_symbols);
-       g_hash_table_insert (cfg->composite_symbols,
-               (gpointer)composite_name,
-               composite);
-
-       if (new) {
-               rspamd_symbols_cache_add_symbol (cfg->cache, composite_name, 0,
-                       NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1);
-       }
 
        val = ucl_object_lookup (obj, "score");
        if (val != NULL && ucl_object_todouble_safe (val, &score)) {
@@ -1537,6 +1529,15 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
                }
        }
 
+       g_hash_table_insert (cfg->composite_symbols,
+                       (gpointer)composite_name,
+                       composite);
+
+       if (new) {
+               rspamd_symbols_cache_add_symbol (cfg->cache, composite_name, 0,
+                               NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1);
+       }
+
        return TRUE;
 }
 
index 00b4e24a5547f93a2432ec6ac720c59f54442955..1e6aa002a5f198bd12609d92e17ce3a8e594758e 100644 (file)
@@ -1445,7 +1445,7 @@ rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len,
 
        /* Strip spaces from the url */
        /* Head spaces */
-       while (g_ascii_isspace (*p) && p < start + len) {
+       while ( p < start + len && g_ascii_isspace (*p)) {
                p ++;
                start ++;
                len --;
@@ -1459,7 +1459,7 @@ rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len,
        /* Trailing spaces */
        p = start + len - 1;
 
-       while (g_ascii_isspace (*p) && p >= start) {
+       while (p >= start && g_ascii_isspace (*p)) {
                p --;
                len --;
 
index e165a4341487f6e2225112e55e1d97e7a54cd633..e9a9ce9b914285d698bd25a770823f38164ed0db 100644 (file)
@@ -304,8 +304,10 @@ rspamd_tokenize_text (gchar *text, gsize len, gboolean is_utf,
 
        buf.begin = text;
        buf.len = len;
+       buf.flags = 0;
        token.begin = NULL;
        token.len = 0;
+       token.flags = 0;
 
        if (compat || !is_utf) {
                func = rspamd_tokenizer_get_word_compat;