Add IOV_MAX

This commit is contained in:
Jeremy Soller
2019-01-13 09:30:37 -07:00
parent 33b539e4c1
commit 5b779448ab
+4 -2
View File
@@ -7,6 +7,8 @@ use header::{errno, unistd};
use platform;
use platform::types::*;
pub const IOV_MAX: c_int = 1024;
#[repr(C)]
pub struct iovec {
iov_base: *mut c_void,
@@ -41,7 +43,7 @@ unsafe fn scatter(iovs: &[iovec], vec: Vec<u8>) {
#[no_mangle]
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;
return -1;
}
@@ -58,7 +60,7 @@ pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> s
#[no_mangle]
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;
return -1;
}