Skip to content
Snippets Groups Projects
Verified Commit 5b779448 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Add IOV_MAX

parent 33b539e4
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ use header::{errno, unistd}; ...@@ -7,6 +7,8 @@ use header::{errno, unistd};
use platform; use platform;
use platform::types::*; use platform::types::*;
pub const IOV_MAX: c_int = 1024;
#[repr(C)] #[repr(C)]
pub struct iovec { pub struct iovec {
iov_base: *mut c_void, iov_base: *mut c_void,
...@@ -41,7 +43,7 @@ unsafe fn scatter(iovs: &[iovec], vec: Vec<u8>) { ...@@ -41,7 +43,7 @@ unsafe fn scatter(iovs: &[iovec], vec: Vec<u8>) {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t { pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t {
if iovcnt < 0 { if iovcnt < 0 || iovcnt > IOV_MAX {
platform::errno = errno::EINVAL; platform::errno = errno::EINVAL;
return -1; return -1;
} }
...@@ -58,7 +60,7 @@ pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> s ...@@ -58,7 +60,7 @@ pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> s
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn writev(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t { pub unsafe extern "C" fn writev(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t {
if iovcnt < 0 { if iovcnt < 0 || iovcnt > IOV_MAX {
platform::errno = errno::EINVAL; platform::errno = errno::EINVAL;
return -1; return -1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment