commit 420c543: [Minor] Add more safety when resolving deps
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Feb 18 17:49:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-02-18 17:47:33 +0000
URL: https://github.com/rspamd/rspamd/commit/420c5434bcec25ccf3d87a90fb81410b273b0afe (HEAD -> master)
[Minor] Add more safety when resolving deps
---
src/libserver/rspamd_symcache.c | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c
index d02638add..e3db8d6ef 100644
--- a/src/libserver/rspamd_symcache.c
+++ b/src/libserver/rspamd_symcache.c
@@ -529,24 +529,31 @@ rspamd_symcache_post_init (struct rspamd_symcache *cache)
dit = rspamd_symcache_find_filter (cache, dep->sym);
if (dit != NULL) {
- if (dit->id == i) {
- msg_err_cache ("cannot add dependency on self: %s -> %s "
- "(resolved to %s)",
- it->symbol, dep->sym, dit->symbol);
+ if (!dit->is_filter) {
+ msg_err_cache ("cannot depend on non filter symbol "
+ "(%s wants to add dependency on %s)",
+ dep->sym, dit->symbol);
}
else {
- rdep = rspamd_mempool_alloc (cache->static_pool,
- sizeof (*rdep));
-
- rdep->sym = dep->sym;
- rdep->item = it;
- rdep->id = i;
- g_ptr_array_add (dit->rdeps, rdep);
- dep->item = dit;
- dep->id = dit->id;
-
- msg_debug_cache ("add dependency from %d on %d", it->id,
- dit->id);
+ if (dit->id == i) {
+ msg_err_cache ("cannot add dependency on self: %s -> %s "
+ "(resolved to %s)",
+ it->symbol, dep->sym, dit->symbol);
+ } else {
+ rdep = rspamd_mempool_alloc (cache->static_pool,
+ sizeof (*rdep));
+
+ rdep->sym = dep->sym;
+ rdep->item = it;
+ rdep->id = i;
+ g_assert (dit->rdeps != NULL);
+ g_ptr_array_add (dit->rdeps, rdep);
+ dep->item = dit;
+ dep->id = dit->id;
+
+ msg_debug_cache ("add dependency from %d on %d", it->id,
+ dit->id);
+ }
}
}
else {
More information about the Commits
mailing list