]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Stat: Fail-safety fix for object expansion
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Feb 2019 12:31:06 +0000 (12:31 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Feb 2019 12:31:06 +0000 (12:31 +0000)
src/libstat/backends/redis_backend.c

index 10d348ac99f63dcc51942f7c910f30139bcd50a7..d7402db983296676f0ef4d2a9811427f22d19430 100644 (file)
@@ -151,7 +151,6 @@ rspamd_redis_expand_object (const gchar *pattern,
        GString *tb;
        const gchar *rcpt = NULL;
        gint err_idx;
-       gboolean expansion_errored = FALSE;
 
        g_assert (ctx != NULL);
        stcf = ctx->stcf;
@@ -214,9 +213,6 @@ rspamd_redis_expand_object (const gchar *pattern,
                                if (elt) {
                                        tlen += strlen (elt);
                                }
-                               else {
-                                       expansion_errored = TRUE;
-                               }
                                break;
                        case 'r':
 
@@ -230,9 +226,6 @@ rspamd_redis_expand_object (const gchar *pattern,
                                if (elt) {
                                        tlen += strlen (elt);
                                }
-                               else {
-                                       expansion_errored = TRUE;
-                               }
                                break;
                        case 'l':
                                if (stcf->label) {
@@ -277,8 +270,8 @@ rspamd_redis_expand_object (const gchar *pattern,
        }
 
 
-       if (target == NULL || task == NULL || expansion_errored) {
-               return tlen;
+       if (target == NULL || task == NULL) {
+               return -1;
        }
 
        *target = rspamd_mempool_alloc (task->task_pool, tlen + 1);
@@ -1305,6 +1298,7 @@ rspamd_redis_parse_classifier_opts (struct redis_stat_ctx *backend,
        }
        else {
                backend->enable_users = FALSE;
+               backend->cbref_user = -1;
        }
 
        elt = ucl_object_lookup (obj, "prefix");