Skip to content

Commit f49bbed

Browse files
committed
fix(utils): for safety, ensure that the root path is not modifiable by the uefi stack
1 parent b0081ef commit f49bbed

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ pub fn resolve_path(default_root_path: Option<&DevicePath>, input: &str) -> Resu
154154
let root_path = text_to_device_path(root.as_str())
155155
.context("unable to convert root to path")?
156156
.to_boxed();
157-
let mut root_path = root_path.as_ref();
158-
let handle = uefi::boot::locate_device_path::<SimpleFileSystem>(&mut root_path)
157+
let root_path = root_path.as_ref();
158+
159+
// locate_device_path modifies the path, so we need to clone it.
160+
let root_path_modifiable = root_path.to_owned();
161+
let handle = uefi::boot::locate_device_path::<SimpleFileSystem>(&mut &*root_path_modifiable)
159162
.context("unable to locate filesystem device path")?;
160163
let subpath = device_path_subpath(path.deref()).context("unable to get device subpath")?;
161164
Ok(ResolvedPath {

0 commit comments

Comments
 (0)