]> git.lizzy.rs Git - rust.git/commitdiff
Fix argument to FIONBIO ioctl
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 7 Sep 2016 15:21:10 +0000 (17:21 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 7 Sep 2016 15:21:10 +0000 (17:21 +0200)
The FIONBIO ioctl takes as argument a pointer to an integer, which
should be either 0 or 1 to indicate whether nonblocking mode is to
be switched off or on.  The type of the pointed-to variable is "int".

However, the set_nonblocking routine in libstd/sys/unix/net.rs passes
a pointer to a libc::c_ulong variable.  This doesn't matter on all
32-bit platforms and on all litte-endian platforms, but it will
break on big-endian 64-bit platforms.

Found while porting Rust to s390x (a big-endian 64-bit platform).

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/libstd/sys/unix/net.rs

index 3f77abd7f44d8f4f56be637a66781da946f300a6..f124ea651ec2c586ff2d317f49e90ae70556abbd 100644 (file)
@@ -213,7 +213,7 @@ pub fn nodelay(&self) -> io::Result<bool> {
     }
 
     pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
-        let mut nonblocking = nonblocking as libc::c_ulong;
+        let mut nonblocking = nonblocking as libc::c_int;
         cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ())
     }