realpath on redox: don't forget the nul terminator

This commit is contained in:
jD91mZM2
2018-10-07 15:12:41 +02:00
parent fba3bf5161
commit 91675b5bc8
2 changed files with 14 additions and 3 deletions
+2 -2
View File
@@ -324,8 +324,8 @@ impl Pal for Sys {
write!(proc_path, "{}", *file).unwrap();
proc_path.push(0);
let len = out.len() - 1;
let read = readlink(CStr::from_bytes_with_nul(&proc_path).unwrap(), &mut out[..len]);
let len = out.len();
let read = readlink(CStr::from_bytes_with_nul(&proc_path).unwrap(), &mut out[..len-1]);
if read < 0 {
return -1;
}
+12 -1
View File
@@ -622,7 +622,18 @@ impl Pal for Sys {
Err(_) => return -1
};
e(syscall::fpath(*file as usize, out)) as c_int
if out.is_empty() {
return 0;
}
let len = out.len();
let read = e(syscall::fpath(*file as usize, &mut out[..len-1]));
if (read as c_int) < 0 {
return -1;
}
out[read as usize] = 0;
0
}
fn rename(oldpath: &CStr, newpath: &CStr) -> c_int {