]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
OSPF: fix stack overflow with too many routes mq-2.16-ospf-stack-overflow
authorMaria Matejka <mq@ucw.cz>
Mon, 23 Dec 2024 16:05:09 +0000 (17:05 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 23 Dec 2024 16:05:09 +0000 (17:05 +0100)
We should not use alloca() in a loop.

This bug happened around 100k routes in OSPF, which
supposedly nobody runs in production.

proto/ospf/rt.c

index d7753ce0aa16d9ae3cd4b9753fd559ab858d867e..6e1544ba5114337dbd90cf1fa617f79a0f253558 100644 (file)
@@ -2068,9 +2068,14 @@ again1:
        .pref = p->p.main_channel->preference,
       };
 
+      struct {
+       ea_list l;
+       eattr a[4];
+      } eal;
+
       if (reload || ort_changed(nf, &a0))
       {
-       a0.eattrs = alloca(sizeof(ea_list) + 4 * sizeof(eattr));
+       a0.eattrs = &eal.l;
        memset(a0.eattrs, 0, sizeof(ea_list));
 
        nf->old_metric1 = nf->n.metric1;