fix(utils): for safety, ensure that the root path is not modifiable by the uefi stack

This commit is contained in:
2025-11-01 01:20:45 -04:00
parent b0081ef9f3
commit f49bbed0d5

View File

@@ -154,8 +154,11 @@ pub fn resolve_path(default_root_path: Option<&DevicePath>, input: &str) -> Resu
let root_path = text_to_device_path(root.as_str()) let root_path = text_to_device_path(root.as_str())
.context("unable to convert root to path")? .context("unable to convert root to path")?
.to_boxed(); .to_boxed();
let mut root_path = root_path.as_ref(); let root_path = root_path.as_ref();
let handle = uefi::boot::locate_device_path::<SimpleFileSystem>(&mut root_path)
// locate_device_path modifies the path, so we need to clone it.
let root_path_modifiable = root_path.to_owned();
let handle = uefi::boot::locate_device_path::<SimpleFileSystem>(&mut &*root_path_modifiable)
.context("unable to locate filesystem device path")?; .context("unable to locate filesystem device path")?;
let subpath = device_path_subpath(path.deref()).context("unable to get device subpath")?; let subpath = device_path_subpath(path.deref()).context("unable to get device subpath")?;
Ok(ResolvedPath { Ok(ResolvedPath {