discover_cached_paths() will write a NULL into a string from a nvlist to
use it as a substring, but does not restore it before return. This
corrupts the nvlist. It should be harmless unless the string is needed
again later, but we should not do this, so let us fix it.
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14612
* our directory cache.
*/
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) {
- if ((dl = zfs_dirnamelen(path)) == -1)
+ int ret;
+ char c = '\0';
+ if ((dl = zfs_dirnamelen(path)) == -1) {
path = (char *)".";
- else
+ } else {
+ c = path[dl];
path[dl] = '\0';
- return (zpool_find_import_scan_dir(hdl, lock, cache,
- path, 0));
+ }
+ ret = zpool_find_import_scan_dir(hdl, lock, cache,
+ path, 0);
+ if (c != '\0')
+ path[dl] = c;
+ return (ret);
}
return (0);
}