Skip to content

Commit 6e7dacc

Browse files
authored
Unrolled build for #155318
Rollup merge of #155318 - Zoxc:ub-issue-50, r=ChrisDenton Use mutable pointers for Unix path buffers This gets mutable pointers for Unix path buffers to ensure they have the right provenance.
2 parents 1b8f2e4 + 7a47964 commit 6e7dacc

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

library/std/src/sys/fs/unix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn get_path_from_fd(fd: c_int) -> Option<PathBuf> {
339339
// alternatives. If a better method is invented, it should be used
340340
// instead.
341341
let mut buf = vec![0; libc::PATH_MAX as usize];
342-
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_ptr()) };
342+
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_mut_ptr()) };
343343
if n == -1 {
344344
cfg_select! {
345345
target_os = "netbsd" => {
@@ -375,7 +375,7 @@ fn get_path_from_fd(fd: c_int) -> Option<PathBuf> {
375375
#[cfg(target_os = "vxworks")]
376376
fn get_path(fd: c_int) -> Option<PathBuf> {
377377
let mut buf = vec![0; libc::PATH_MAX as usize];
378-
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_ptr()) };
378+
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_mut_ptr()) };
379379
if n == -1 {
380380
return None;
381381
}

library/std/src/sys/paths/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
207207
cvt(libc::sysctl(
208208
mib.as_ptr(),
209209
mib.len() as libc::c_uint,
210-
path.as_ptr() as *mut libc::c_void,
210+
path.as_mut_ptr() as *mut libc::c_void,
211211
&mut path_len,
212212
ptr::null(),
213213
0,

0 commit comments

Comments
 (0)