Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Dec 2025 14:12:00 +0000
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 792221630bf4 - main - rtsold: Fix a buffer leak if we fail to read the default router sysctl
Message-ID:  <6936dcb0.2fe40.4932bc03@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help

The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=792221630bf4e58fcd923547bab689f4497613d8

commit 792221630bf4e58fcd923547bab689f4497613d8
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-12-04 15:00:46 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-12-08 14:08:13 +0000

    rtsold: Fix a buffer leak if we fail to read the default router sysctl
    
    MFC after:      1 week
    Reported by:    Kevin Day <kevin@your.org>
---
 usr.sbin/rtsold/cap_sendmsg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/rtsold/cap_sendmsg.c b/usr.sbin/rtsold/cap_sendmsg.c
index 6e7f156fbe62..36c68b7ba78d 100644
--- a/usr.sbin/rtsold/cap_sendmsg.c
+++ b/usr.sbin/rtsold/cap_sendmsg.c
@@ -151,8 +151,10 @@ probe_defrouters(uint32_t ifindex, uint32_t linkid)
 	buf = malloc(len);
 	if (buf == NULL)
 		return (-1);
-	if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) < 0)
+	if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) < 0) {
+		free(buf);
 		return (-1);
+	}
 	ep = (struct in6_defrouter *)(void *)(buf + len);
 	for (p = (struct in6_defrouter *)(void *)buf; p < ep; p++) {
 		if (ifindex != p->if_index)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6936dcb0.2fe40.4932bc03>