Skip to content

Commit

Permalink
fix(sandbox): canonicalize guest paths before lookup
Browse files Browse the repository at this point in the history
We also began using .display().to_string(), so as to drop non-Unicode
characters, similarly to when parsing the mappings.
  • Loading branch information
n0toose authored and jounathaen committed Jan 9, 2025
1 parent 9fa4294 commit da4b63e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/isolation/filemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ impl UhyveFileMap {
///
/// * `guest_path` - The guest path that is to be looked up in the map.
pub fn get_host_path(&mut self, guest_path: &str) -> Option<OsString> {
let host_path = self.files.get(guest_path).map(OsString::from);
// TODO: Replace clean-path in favor of Path::normalize_lexically, which has not
// been implemented yet. See: https://github.com/rust-lang/libs-team/issues/396
let requested_guest_pathbuf = clean(guest_path);
let host_path = self
.files
.get(&requested_guest_pathbuf.display().to_string())
.map(OsString::from);
if host_path.is_some() {
host_path
} else {
Expand All @@ -69,9 +75,6 @@ impl UhyveFileMap {
return None;
}

let requested_guest_pathbuf = clean(PathBuf::from(guest_path));
// TODO: Replace clean-path in favor of Path::normalize_lexically, which has not
// been implemented yet. See: https://github.com/rust-lang/libs-team/issues/396
if let Some(parent_of_guest_path) = requested_guest_pathbuf.parent() {
debug!("The file is in a child directory, searching for a parent directory...");
for searched_parent_guest in parent_of_guest_path.ancestors() {
Expand Down

0 comments on commit da4b63e

Please sign in to comment.