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
97143b9d31 was merged.

The code has been changed to sanitize the output from `kmem_scnprintf()`.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14111
This commit is contained in:
Richard Yao 2022-11-01 16:58:17 -04:00 committed by GitHub
parent fdc59cf563
commit da3d266672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}