aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libzutil/os/linux/zutil_import_os.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c
index 61c42cf2e..84c3cb44f 100644
--- a/lib/libzutil/os/linux/zutil_import_os.c
+++ b/lib/libzutil/os/linux/zutil_import_os.c
@@ -283,21 +283,20 @@ zpool_default_search_paths(size_t *count)
static int
zfs_path_order(char *name, int *order)
{
- int i = 0, error = ENOENT;
- char *dir, *env, *envdup;
+ int i, error = ENOENT;
+ char *dir, *env, *envdup, *tmp = NULL;
env = getenv("ZPOOL_IMPORT_PATH");
if (env) {
envdup = strdup(env);
- dir = strtok(envdup, ":");
- while (dir) {
+ for (dir = strtok_r(envdup, ":", &tmp), i = 0;
+ dir != NULL;
+ dir = strtok_r(NULL, ":", &tmp), i++) {
if (strncmp(name, dir, strlen(dir)) == 0) {
*order = i;
error = 0;
break;
}
- dir = strtok(NULL, ":");
- i++;
}
free(envdup);
} else {