Skip to content

Commit

Permalink
validate whether addr is null before constructing slice
Browse files Browse the repository at this point in the history
Signed-off-by: YangKeao <[email protected]>
  • Loading branch information
YangKeao committed Jan 19, 2023
1 parent 0760534 commit 83aff0f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/addr_validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ fn open_pipe() -> nix::Result<()> {
}

pub fn validate(addr: *const libc::c_void) -> bool {
if addr.is_null() {
return false;
}

const CHECK_LENGTH: usize = 2 * size_of::<*const libc::c_void>() / size_of::<u8>();

// read data in the pipe
Expand Down

0 comments on commit 83aff0f

Please sign in to comment.