From 2a8c6060823f98360763038fbb79d2d5922bb6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 20 May 2021 22:49:59 +0200 Subject: [PATCH] libzutil: zfs_resolve_shortname: remove strtok MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia ZiemiaƄska Closes #12094 --- lib/libzutil/zutil_device_path.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libzutil/zutil_device_path.c b/lib/libzutil/zutil_device_path.c index 518f941615..bcdc72baa6 100644 --- a/lib/libzutil/zutil_device_path.c +++ b/lib/libzutil/zutil_device_path.c @@ -41,18 +41,18 @@ int zfs_resolve_shortname(const char *name, char *path, size_t len) { int i, error = -1; - char *dir, *env, *envdup; + char *dir, *env, *envdup, *tmp = NULL; env = getenv("ZPOOL_IMPORT_PATH"); errno = ENOENT; if (env) { envdup = strdup(env); - dir = strtok(envdup, ":"); - while (dir && error) { + for (dir = strtok_r(envdup, ":", &tmp); + dir != NULL && error != 0; + dir = strtok_r(NULL, ":", &tmp)) { (void) snprintf(path, len, "%s/%s", dir, name); error = access(path, F_OK); - dir = strtok(NULL, ":"); } free(envdup); } else {