Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Commit

Permalink
Fix UB in offset calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Apr 21, 2015
1 parent 9aa9fb8 commit 12b30f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ extern "C" {

fn sun_path_offset() -> usize {
unsafe {
&(*(0 as *const libc::sockaddr_un)).sun_path as *const _ as usize
let addr: libc::sockaddr_un = mem::zeroed();
let base = &addr as *const _ as usize;
let path = &addr.sun_path as *const _ as usize;
path - base
}
}

Expand Down

0 comments on commit 12b30f5

Please sign in to comment.