Skip to content

Commit da3d266

Browse files
authored
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 97143b9 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
1 parent fdc59cf commit da3d266

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/libzfs/os/freebsd/libzfs_compat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ libzfs_error_init(int error)
202202
size_t msglen = sizeof (errbuf);
203203

204204
if (modfind("zfs") < 0) {
205-
size_t len = kmem_scnprintf(msg, msglen, dgettext(TEXT_DOMAIN,
205+
size_t len = snprintf(msg, msglen, dgettext(TEXT_DOMAIN,
206206
"Failed to load %s module: "), ZFS_KMOD);
207+
if (len >= msglen)
208+
len = msglen - 1;
207209
msg += len;
208210
msglen -= len;
209211
}

0 commit comments

Comments
 (0)