[PATCH 1/2] Filter: Fix comparison of BGP path mask
Add a missing return statement. Path masks with the same length were all considered the same. Comparing two with different length would cause out-of-bounds memory access. This bug was introduced by version 2.0.4, commit 4c553c5a5b40 ("Filter refactoring: dropped the recursion from the interpreter", 2018-12-27). --- filter/data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/filter/data.c b/filter/data.c index 402202554c2f..9547a4c84833 100644 --- a/filter/data.c +++ b/filter/data.c @@ -230,6 +230,7 @@ static int pm_same(const struct f_path_mask *m1, const struct f_path_mask *m2) { if (m1->len != m2->len) + return 0; for (uint i=0; i<m1->len; i++) if (!pmi_same(&(m1->item[i]), &(m2->item[i]))) -- 2.27.0
This is a follow-up for commit ef113c6f7253 ("Filter: Allow to use sets in path masks", 2019-08-06). Compare the content of PM_ASN_SET in path masks. A reconfiguration was not properly triggering a reload of affected protocols when the members of a set in a path mask change. Also, update the printing code to so that it can display sets in a path mask. --- filter/data.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/filter/data.c b/filter/data.c index 9547a4c84833..7c33d2cb681a 100644 --- a/filter/data.c +++ b/filter/data.c @@ -121,6 +121,11 @@ pm_format(const struct f_path_mask *p, buffer *buf) buffer_print(buf, "%u..%u ", p->item[i].from, p->item[i].to); break; + case PM_ASN_SET: + tree_format(p->item[i].set, buf); + buffer_puts(buf, " "); + break; + case PM_ASN_EXPR: ASSERT(0); } @@ -221,6 +226,10 @@ pmi_same(const struct f_path_mask_item *mi1, const struct f_path_mask_item *mi2) if (mi1->to != mi2->to) return 0; break; + case PM_ASN_SET: + if (!same_tree(mi1->set, mi2->set)) + return 0; + break; } return 1; -- 2.27.0
On Fri, Jun 26, 2020 at 04:44:09PM +0900, Kazuki Yamaguchi wrote:
Add a missing return statement. Path masks with the same length were all considered the same. Comparing two with different length would cause out-of-bounds memory access.
Hi Thanks, merged (both). -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
participants (2)
-
Kazuki Yamaguchi -
Ondrej Zajicek