Skip to content

Commit

Permalink
Auto merge of #27 - antrik:fix-server, r=Ms2ger
Browse files Browse the repository at this point in the history
Linux: Don't pass uninitialised memory as pointers to libc::connect()

I don't know whether there are constellations where taking a reference
to a binding containing mem::uninitialized() actually creates a proper
NULL pointer -- but it certainly doesn't on my system when using the
rustc snapshot from Servo.

Either way, creating explicit NULL pointers seems way more correct.

This fixes the other four testsuite failures, as well as servo -M
  • Loading branch information
bors-servo committed Jan 8, 2016
2 parents 1b95d54 + 30abbf5 commit 38e93e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions platform/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ impl UnixOneShotServer {
Vec<OpaqueUnixChannel>,
Vec<UnixSharedMemory>),UnixError> {
unsafe {
let mut sockaddr = mem::uninitialized();
let mut sockaddr_len = mem::uninitialized();
let client_fd = libc::accept(self.fd, &mut sockaddr, &mut sockaddr_len);
let sockaddr: *mut sockaddr = ptr::null_mut();
let sockaddr_len: *mut socklen_t = ptr::null_mut();
let client_fd = libc::accept(self.fd, sockaddr, sockaddr_len);
if client_fd < 0 {
return Err(UnixError::last())
}
Expand Down

0 comments on commit 38e93e8

Please sign in to comment.