diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-24 14:58:10 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-24 14:58:10 +0000 |
commit | d18fba75b622b4f60f75e73d697a3d20a2c226a0 (patch) | |
tree | b5018e742f2ac01d2cb77bcab09f533ae2f481fb /src | |
parent | a136f681432ba4b1ea0b127a3d80fdf4b004ae53 (diff) | |
download | rspamd-d18fba75b622b4f60f75e73d697a3d20a2c226a0.tar.gz rspamd-d18fba75b622b4f60f75e73d697a3d20a2c226a0.zip |
Fix issue with changing number of regexps in a cache
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/re_cache.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index f1c67b3cb..b2cb47f19 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -343,6 +343,10 @@ rspamd_re_cache_init (struct rspamd_re_cache *cache, struct rspamd_config *cfg) sizeof (fl)); } + rspamd_cryptobox_hash_final (&st_global, hash_out); + rspamd_snprintf (cache->hash, sizeof (cache->hash), "%*xs", + (gint) rspamd_cryptobox_HASHBYTES, hash_out); + /* Now finalize all classes */ g_hash_table_iter_init (&it, cache->re_classes); @@ -350,6 +354,14 @@ rspamd_re_cache_init (struct rspamd_re_cache *cache, struct rspamd_config *cfg) re_class = v; if (re_class->st) { + /* + * We finally update all classes with the number of expressions + * in the cache to ensure that if even a single re has been changed + * we won't be broken due to id mismatch + */ + rspamd_cryptobox_hash_update (re_class->st, + (gpointer)&cache->re->len, + sizeof (cache->re->len)); rspamd_cryptobox_hash_final (re_class->st, hash_out); rspamd_snprintf (re_class->hash, sizeof (re_class->hash), "%*xs", (gint) rspamd_cryptobox_HASHBYTES, hash_out); @@ -358,10 +370,6 @@ rspamd_re_cache_init (struct rspamd_re_cache *cache, struct rspamd_config *cfg) } } - rspamd_cryptobox_hash_final (&st_global, hash_out); - rspamd_snprintf (cache->hash, sizeof (cache->hash), "%*xs", - (gint) rspamd_cryptobox_HASHBYTES, hash_out); - #ifdef WITH_HYPERSCAN const gchar *platform = "generic"; rspamd_fstring_t *features = rspamd_fstring_new (); |