On Mon, Dec 28, 2020 at 07:23:51PM +0100, Ondrej Zajicek wrote:
> On Mon, Dec 28, 2020 at 06:47:29PM +0100, Damian Zaremba wrote:
> > Hi,
> > 
> > Thanks for the fast response and fix - I can confirm that is working as
> > expected on my side.
> > 
> > Unfortunately I did discover another segfault (testing from current master)
> > which appears to be due to `net` being uninitialised in the route specific
> > filters;
> 
> > This was originally triggered in a function call that used an `if net ~ set`
> > operation, so while the above config doesn't really make practical sense
> > it's the smallest filter I could make to repeatedly trigger the issue.

Hi

Fixed by the attached patch. Implementation of 'net' attribute is kind of
ugly and requires some hacks, which were missing here.

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: [email protected])
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
commit ea3c6c1a15ce9b93f583f96919c70f7a2fd34e98
Author: Ondrej Zajicek (work) <[email protected]>
Date:   Mon Dec 28 21:19:27 2020 +0100

    Static: Fix handling of 'net' attribute in per-route filters
    
    We need to define 'net' field temporarily as it may be accessed by
    per-route filters.
    
    Thanks to Damian Zaremba for the bugreport.

diff --git a/proto/static/static.c b/proto/static/static.c
index 941e916f..31b7f5d6 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -106,8 +106,19 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
   e->pflags = 0;
 
   if (r->cmds)
+  {
+    /* Create a temporary table node */
+    e->net = alloca(sizeof(net) + r->net->length);
+    memset(e->net, 0, sizeof(net) + r->net->length);
+    net_copy(e->net->n.addr, r->net);
+
+    /* Evaluate the filter */
     f_eval_rte(r->cmds, &e, static_lp);
 
+    /* Remove the temporary node */
+    e->net = NULL;
+  }
+
   rte_update2(p->p.main_channel, r->net, e, a->src);
   r->state = SRS_CLEAN;
 

Reply via email to