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.
This commit is contained in:
Stuart Cook
2026-04-17 16:17:51 +10:00
committed by GitHub
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -339,7 +339,7 @@ fn get_path(fd: c_int) -> Option<PathBuf> {
// alternatives. If a better method is invented, it should be used
// instead.
let mut buf = vec![0; libc::PATH_MAX as usize];
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_ptr()) };
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_mut_ptr()) };
if n == -1 {
cfg_select! {
target_os = "netbsd" => {
@@ -375,7 +375,7 @@ fn get_path(fd: c_int) -> Option<PathBuf> {
#[cfg(target_os = "vxworks")]
fn get_path(fd: c_int) -> Option<PathBuf> {
let mut buf = vec![0; libc::PATH_MAX as usize];
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_ptr()) };
let n = unsafe { libc::ioctl(fd, libc::FIOGETNAME, buf.as_mut_ptr()) };
if n == -1 {
return None;
}
+1 -1
View File
@@ -207,7 +207,7 @@ fn sysctl() -> io::Result<PathBuf> {
cvt(libc::sysctl(
mib.as_ptr(),
mib.len() as libc::c_uint,
path.as_ptr() as *mut libc::c_void,
path.as_mut_ptr() as *mut libc::c_void,
&mut path_len,
ptr::null(),
0,