Date: Sat, 09 May 2026 15:55:03 +0000 From: Hartmut Brandt <harti@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Chuck Silvers <chs@FreeBSD.org> Subject: git: 7906084ba2fd - main - Fix some memory leaks when fetching the mibII. Message-ID: <69ff58d7.336ba.123f34ad@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by harti: URL: https://cgit.FreeBSD.org/src/commit/?id=7906084ba2fd50022f38ce2e8d0bcef212a4ff19 commit 7906084ba2fd50022f38ce2e8d0bcef212a4ff19 Author: Chuck Silvers <chs@FreeBSD.org> AuthorDate: 2026-05-09 15:52:14 +0000 Commit: Hartmut Brandt <harti@FreeBSD.org> CommitDate: 2026-05-09 15:52:14 +0000 Fix some memory leaks when fetching the mibII. Reviewed by: glebius Sponsored by: Netflix Differential Revision: <https://reviews.freebsd.org/D55998> --- contrib/bsnmp/snmp_mibII/mibII.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/bsnmp/snmp_mibII/mibII.c b/contrib/bsnmp/snmp_mibII/mibII.c index 59f3836d1ede..4cf4f231facc 100644 --- a/contrib/bsnmp/snmp_mibII/mibII.c +++ b/contrib/bsnmp/snmp_mibII/mibII.c @@ -485,6 +485,7 @@ mib_fetch_ifmib(struct mibif *ifp) syslog(LOG_WARNING, "sysctl linkmib estimate (%s): %m", ifp->name); if (ifp->specmib != NULL) { + free(ifp->specmib); ifp->specmib = NULL; ifp->specmiblen = 0; } @@ -492,6 +493,7 @@ mib_fetch_ifmib(struct mibif *ifp) } if (len == 0) { if (ifp->specmib != NULL) { + free(ifp->specmib); ifp->specmib = NULL; ifp->specmiblen = 0; } @@ -500,6 +502,7 @@ mib_fetch_ifmib(struct mibif *ifp) if (ifp->specmiblen != len) { if ((newmib = realloc(ifp->specmib, len)) == NULL) { + free(ifp->specmib); ifp->specmib = NULL; ifp->specmiblen = 0; goto out; @@ -510,6 +513,7 @@ mib_fetch_ifmib(struct mibif *ifp) if (sysctl(name, nitems(name), ifp->specmib, &len, NULL, 0) == -1) { syslog(LOG_WARNING, "sysctl linkmib (%s): %m", ifp->name); if (ifp->specmib != NULL) { + free(ifp->specmib); ifp->specmib = NULL; ifp->specmiblen = 0; } @@ -546,9 +550,11 @@ mib_fetch_ifmib(struct mibif *ifp) alias_maxlen = MIBIF_ALIAS_SIZE_MAX; /* + * Free any alias memory allocated by a previous call. * Allocate maximum memory for a buffer and later reallocate * to free extra memory. */ + free(ifp->alias); if ((ifp->alias = malloc(alias_maxlen)) == NULL) { syslog(LOG_WARNING, "malloc(%d) failed: %m", (int)alias_maxlen); goto fin;home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69ff58d7.336ba.123f34ad>
