Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: fix filterset leak in rde_filter_free()
To:
tech@openbsd.org
Date:
Thu, 30 Apr 2026 17:05:34 +0200

Download raw body.

Thread
rde_filter_free() needs to unref the rde_filtersets of all rules before
calling free().

There is no other referenced or allocated data in that array. To verify
check out rde_filter_fill().
-- 
:wq Claudio

Index: rde_filter.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
diff -u -p -r1.148 rde_filter.c
--- rde_filter.c	27 Apr 2026 15:06:01 -0000	1.148
+++ rde_filter.c	30 Apr 2026 15:02:16 -0000
@@ -483,8 +483,13 @@ static struct rde_filtertable filter = C
 static void
 rde_filter_free(struct rde_filter *rf)
 {
+	size_t i;
+
 	if (rf == NULL)
 		return;
+
+	for (i = 0; i < rf->len; i++)
+		rde_filterset_unref(rf->rules[i].rde_set);
 
 	rdemem.filter_size -= sizeof(*rf) + rf->len * sizeof(rf->rules[0]);
 	rdemem.filter_cnt--;