]> git.99rst.org Git - openwrt-packages.git/commitdiff
olsrd: initialize the LQ multiplier list pointer in the ubus handler
authorJosef Schlehofer <redacted>
Thu, 6 Aug 2026 10:39:35 +0000 (12:39 +0200)
committerNick Hainke <redacted>
Thu, 13 Aug 2026 21:21:19 +0000 (23:21 +0200)
The ubus add_interface handler allocates a struct olsr_lq_mult with
malloc() and assigns only ->addr and ->value, leaving ->next
uninitialized before the node is published into cnf->lq_mult. olsrd
walks that list with

    for (mult = cnf->lq_mult; mult != NULL; mult = mult->next)

so the first traversal follows an indeterminate pointer.

Chain the new node onto the existing list, which is what the
configuration file parser does for LinkQualityMult in
src/cfgparser/oparse.y. This also makes the orig_lq_mult_cnt++ on
the next line consistent, since the entry really is prepended to the
list instead of replacing it.

Reported-by: openwrt-ai[bot]
Signed-off-by: Josef Schlehofer <redacted>
Co-authored-by: Claude Fable 5 <redacted>
net/olsrd/src/src/ubus.c

index 37c2dbf99d1c188c200deaab59b1b58f8bf8d789..88caed13c418f56473cebd67ae86d51056d9a63a 100644 (file)
@@ -83,6 +83,7 @@ static int olsrd_ubus_add_interface(struct ubus_context *ctx_local,
     double lqm_value = atof(lqm);
     mult->addr = addr;
     mult->value = (uint32_t)(lqm_value * LINK_LOSS_MULTIPLIER);
+    mult->next = tmp_ifs->cnf->lq_mult;
     tmp_ifs->cnf->lq_mult = mult;
     tmp_ifs->cnf->orig_lq_mult_cnt++;
   }
git clone https://git.99rst.org/PROJECT