From b4e55fc5e86ad6ed38b04ed121890227dcc00463 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 11 Aug 2017 18:54:26 +0200 Subject: [PATCH] lib: fix prefix list trie corruption The specific code here needs to establish an absolute order of more specific to less specific possible matches in a prefix list. This is indirectly checked by an assert on insertion, because the "next best" entry is required to be consistent even when joining multiple chains of candidates. Unfortunately, trie_install_fn() would insert entries too far ahead in the chain if another entry with higher sequence number was seen. This breaks the trie and (rightfully) triggers the assertion failure on insert. Fixes: #937 Signed-off-by: David Lamparter --- lib/plist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plist.c b/lib/plist.c index d7a0db6807..b0cf42ca49 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -538,7 +538,8 @@ static void trie_install_fn(struct prefix_list_entry *object, return; if ((*updptr)->prefix.prefixlen < object->prefix.prefixlen) break; - if ((*updptr)->seq > object->seq) + if ((*updptr)->prefix.prefixlen == object->prefix.prefixlen + && (*updptr)->seq > object->seq) break; updptr = &(*updptr)->next_best; } -- 2.39.5