From c0c41ab39645d83f2a0bd37dba93886251b22433 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Mon, 8 Jun 2020 08:58:13 -0700 Subject: [PATCH] Don't erase final byte of envblock When we copy the envblock's contents out, we currently treat it as a normal C string. However, this functionality is supposed to more closely emulate interacting with a file. As a consequence, we were incorrectly truncating the contents of the envblock by replacing the final byte of the buffer with a null character. Reviewed-by: Pavel Zakharov Reviewed-by: Matthew Ahrens Reviewed-by: Brian Behlendorf Signed-off-by: Paul Dagnelie Closes #10405 --- lib/libzfs/libzfs_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 6123020f78b5..96ac426221d1 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -4539,7 +4539,7 @@ zpool_get_bootenv(zpool_handle_t *zhp, char *outbuf, size_t size, off_t offset) return (0); } - strlcpy(outbuf, envmap + offset, size); + strncpy(outbuf, envmap + offset, size); int bytes = MIN(strlen(envmap + offset), size); fnvlist_free(nvl); return (bytes);