Skip to content

Commit

Permalink
Fixed a bug where UnixAddr::new_abstract forgot to count the null-byte.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Svensson committed Sep 17, 2016
1 parent 3c8ff4a commit 26e1b6d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl UnixAddr {
.. mem::zeroed()
};

if path.len() > ret.sun_path.len() {
if path.len() + 1 > ret.sun_path.len() {
return Err(Error::Sys(Errno::ENAMETOOLONG));
}

Expand All @@ -401,7 +401,7 @@ impl UnixAddr {
ret.sun_path.as_mut_ptr().offset(1) as *mut u8,
path.len());

Ok(UnixAddr(ret, path.len()))
Ok(UnixAddr(ret, path.len() + 1))
}
}

Expand Down

0 comments on commit 26e1b6d

Please sign in to comment.