Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with path_rename moving down 1 directory #1764

Merged
merged 5 commits into from
Nov 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2030,12 +2030,16 @@ pub fn path_rename(
new_path: WasmPtr<u8, Array>,
new_path_len: u32,
) -> __wasi_errno_t {
debug!("wasi::path_rename");
debug!(
"wasi::path_rename: old_fd = {}, new_fd = {}",
old_fd, new_fd
);
let (memory, mut state) = env.get_memory_and_wasi_state(0);
let source_str = get_input_str!(memory, old_path, old_path_len);
let source_path = std::path::Path::new(source_str);
let target_str = get_input_str!(memory, new_path, new_path_len);
let target_path = std::path::Path::new(target_str);
debug!("=> rename from {} to {}", source_str, target_str);

{
let source_fd = wasi_try!(state.fs.get_fd(old_fd));
Expand All @@ -2059,8 +2063,6 @@ pub fn path_rename(
return __WASI_EEXIST;
}
let mut out_path = path.clone();
// remove fd's own name which will be double counted
out_path.pop();
out_path.push(target_path);
out_path
}
Expand Down