From f49bbed0d5fdff99907571e0da04db5550a78b0c Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 1 Nov 2025 01:20:45 -0400 Subject: [PATCH] fix(utils): for safety, ensure that the root path is not modifiable by the uefi stack --- src/utils.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 91bdfd4..66703cc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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()) .context("unable to convert root to path")? .to_boxed(); - let mut root_path = root_path.as_ref(); - let handle = uefi::boot::locate_device_path::(&mut root_path) + let root_path = root_path.as_ref(); + + // 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::(&mut &*root_path_modifiable) .context("unable to locate filesystem device path")?; let subpath = device_path_subpath(path.deref()).context("unable to get device subpath")?; Ok(ResolvedPath {