From 47a7062772766c8a532df157a7be681327c20ea6 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Sat, 11 Mar 2023 15:25:04 -0500 Subject: [PATCH] zpool_valid_proplist() should not corrupt nvpair name string on error The strings returned from parsing nvlists should be immutable, but to simplify the code when we want a substring from it, we sometimes will write a NULL into it and then restore the value afterward. Provided there is no concurrent access, this is okay, unless we forget to restore the value afterward. This was caught when constifying string functions related to nvlists. Reviewed-by: Tino Reichardt Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14612 --- lib/libzfs/libzfs_pool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 82965f8b9..ac25ecf9e 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -694,6 +694,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, if (strval[0] != '\0' && (stat64(strval, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))) { + *slash = '/'; zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "'%s' is not a valid directory"), strval);