]> git.proxmox.com Git - mirror_zfs.git/commit
FreeBSD: Fix leaked strings in libspl mnttab
authorRyan Moeller <ryan@iXsystems.com>
Fri, 14 Jan 2022 20:38:32 +0000 (15:38 -0500)
committerGitHub <noreply@github.com>
Fri, 14 Jan 2022 20:38:32 +0000 (12:38 -0800)
commit69c5e694a18cb6ab66a48292c7f9fa94902f8378
treee613cb1eaa3f66a46d29ac5058f6c5a8ec138c81
parent12bd322dde069ca1600e2839154be793a7c8ae74
FreeBSD: Fix leaked strings in libspl mnttab

The FreeBSD implementations of various libspl functions for getting
mounted device information were found to leak several strings which
were being allocated in statfs2mnttab but never freed.

The Solaris getmntany(3C) and related interfaces are expected to return
strings residing in static buffers that need to be copied rather than
freed by the caller.

Use static thread-local storage to stash the mnttab structure strings
from FreeBSD's statfs info rather than strings allocated on the heap by
strdup(3).

While here, remove some stray commented out lines.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #12961
lib/libspl/os/freebsd/mnttab.c