Skip to content

Commit

Permalink
Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSD
Browse files Browse the repository at this point in the history
Technically these functions don't violate Rust's safety rules, because
libc::ptrace doesn't dereference those pointer args.  Instead, it passes
them directly to the kernel.
  • Loading branch information
asomers committed Jan 22, 2022
1 parent 475da53 commit 91049bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sys/ptrace/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ pub fn step<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> {
}

/// Reads a word from a processes memory at the given address
// Technically, ptrace doesn't dereference the pointer. It passes it directly
// to the kernel.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn read(pid: Pid, addr: AddressType) -> Result<c_int> {
unsafe {
// Traditionally there was a difference between reading data or
Expand All @@ -176,6 +179,9 @@ pub fn read(pid: Pid, addr: AddressType) -> Result<c_int> {
}

/// Writes a word into the processes memory at the given address
// Technically, ptrace doesn't dereference the pointer. It passes it directly
// to the kernel.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn write(pid: Pid, addr: AddressType, data: c_int) -> Result<()> {
unsafe { ptrace_other(Request::PT_WRITE_D, pid, addr, data).map(drop) }
}

0 comments on commit 91049bc

Please sign in to comment.