diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-15 17:45:17 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-15 17:45:17 +0000 |
commit | 410f6688754aaca5f3b993f0781e196afcfbf66e (patch) | |
tree | e0ba13e59ed7492641735942834db330ba9ce981 /src/libserver | |
parent | 71922cf7ffa8aa576c823f13f8663e6efa31ba17 (diff) | |
download | rspamd-410f6688754aaca5f3b993f0781e196afcfbf66e.tar.gz rspamd-410f6688754aaca5f3b993f0781e196afcfbf66e.zip |
[Fix] Do not allow dependencies on self
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/symbols_cache.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 5f710d459..5db23bd66 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -413,6 +413,8 @@ rspamd_symbols_cache_post_init (struct symbols_cache *cache) "%s is missing", ddep->from, ddep->to, ddep->from); } else { + msg_debug_cache ("delayed between %s(%d) -> %s", ddep->from, + it->id, ddep->to); rspamd_symbols_cache_add_dependency (cache, it->id, ddep->to); } @@ -457,15 +459,24 @@ rspamd_symbols_cache_post_init (struct symbols_cache *cache) dit = g_ptr_array_index (cache->items_by_id, dit->parent); } - 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_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 { msg_err_cache ("cannot find dependency on symbol %s", dep->sym); |