mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 02:49:32 +03:00
discover_cached_paths() should not corrupt nvlist string value
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
This commit is contained in:
parent
47a7062772
commit
50f6934b9c
@ -1564,12 +1564,19 @@ discover_cached_paths(libpc_handle_t *hdl, nvlist_t *nv,
|
||||
* 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user