aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Zaborski <oshogbo@FreeBSD.org>2026-06-19 11:58:17 +0000
committerMariusz Zaborski <oshogbo@FreeBSD.org>2026-06-19 11:58:17 +0000
commit28ddd11d91f860df9b9be485c5b0526c10b4aec1 (patch)
treec15307d12747d275d43c90a3c4155e472ab2b73d
parent63442ceae5ed31ad45e401f5fe0010b824bc2b38 (diff)
bsnmpd/snmp_hostres: fix hrFSTable remoteMountPoint leak
Free the previous value before re-strdup'ing, and initialise remoteMountPoint to NULL in fs_entry_create() so the free() is safe on the newly-created path Observed via a dtrace leak snapshot on 15.0-RELEASE-p4: data leaked = 1983, count = 1683 libc.so.7`malloc+0xa8 snmp_hostres.so.6`fs_tbl_process_statfs_entry+0x276 snmp_hostres.so.6`refresh_storage_tbl+0x502 snmp_hostres.so.6`op_hrStorageTable+0x1a libbsnmp.so.7`0x2a2b1892ba3d libbsnmp.so.7`snmp_getbulk+0x37f Reviewed by: sjg, ngie Differential Revision: https://reviews.freebsd.org/D57604
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
index bdc20d19a372..147522036bf9 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c
@@ -205,6 +205,7 @@ fs_entry_create(const char *name)
free(entry);
return (NULL);
}
+ entry->remoteMountPoint = NULL;
entry->index = map->hrIndex;
map->entry = entry;
@@ -352,6 +353,9 @@ fs_tbl_process_statfs_entry(const struct statfs *fs_p, int32_t storage_idx)
(entry = fs_entry_create(fs_p->f_mntonname)) != NULL) {
entry->flags |= HR_FS_FOUND;
+ free(entry->remoteMountPoint);
+ entry->remoteMountPoint = NULL;
+
if (!(fs_p->f_flags & MNT_LOCAL)) {
/* this is a remote mount */
entry->remoteMountPoint = strdup(fs_p->f_mntfromname);