summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2022-11-01 16:58:17 -0400
committerGitHub <[email protected]>2022-11-01 13:58:17 -0700
commitda3d2666728ed21707bd66182c4077f4adcd61aa (patch)
tree2da6d77090bf6dd9ac1aa2823d52621f81065d6f
parentfdc59cf56356858c00b9f06fd9fe11ab60ad7790 (diff)
FreeBSD: Fix regression from kmem_scnprintf() in libzfs
kmem_scnprintf() is only available in libzpool. Recent buildbot issues with showing FreeBSD results kept us from seeing this before 97143b9d314d54409244f3995576d8cc8c1ebf0a was merged. The code has been changed to sanitize the output from `kmem_scnprintf()`. Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14111
-rw-r--r--lib/libzfs/os/freebsd/libzfs_compat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libzfs/os/freebsd/libzfs_compat.c b/lib/libzfs/os/freebsd/libzfs_compat.c
index 5e280cbae..d1c1fea7f 100644
--- a/lib/libzfs/os/freebsd/libzfs_compat.c
+++ b/lib/libzfs/os/freebsd/libzfs_compat.c
@@ -202,8 +202,10 @@ libzfs_error_init(int error)
size_t msglen = sizeof (errbuf);
if (modfind("zfs") < 0) {
- size_t len = kmem_scnprintf(msg, msglen, dgettext(TEXT_DOMAIN,
+ size_t len = snprintf(msg, msglen, dgettext(TEXT_DOMAIN,
"Failed to load %s module: "), ZFS_KMOD);
+ if (len >= msglen)
+ len = msglen - 1;
msg += len;
msglen -= len;
}