summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-08-05 16:35:45 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-08-05 16:35:45 +0000
commit34872dd86ae891d7c355cc7deb62d0f1a415ba9d (patch)
tree8b2fe8e8d970f0732b84ed2d1b883cf0b173b4e6 /sys/kern
parent1acf6c1fcc4ef49eb430bc1707769054661f73da (diff)
return EMSGSIZE, not EINVAL is msg_iovlen <= 0 as per XPG 4.2
When comparing against UIO_SMALLIOV/UIO_MAXIOV check for >, not >=
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_syscalls.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 0825988e79e..52e5b3458ce 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.11 1998/08/05 16:05:18 millert Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.12 1998/08/05 16:35:44 millert Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -385,14 +385,12 @@ sys_sendmsg(p, v, retval)
error = copyin(SCARG(uap, msg), (caddr_t)&msg, sizeof (msg));
if (error)
return (error);
- if (msg.msg_iovlen <= 0)
- return (EINVAL);
- if (msg.msg_iovlen >= UIO_SMALLIOV) {
- if (msg.msg_iovlen >= UIO_MAXIOV)
- return (EMSGSIZE);
+ if (msg.msg_iovlen <= 0 || msg.msg_iovlen > UIO_MAXIOV)
+ return (EMSGSIZE);
+ if (msg.msg_iovlen > UIO_SMALLIOV)
MALLOC(iov, struct iovec *,
sizeof(struct iovec) * msg.msg_iovlen, M_IOV, M_WAITOK);
- } else
+ else
iov = aiov;
if (msg.msg_iovlen &&
(error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
@@ -570,14 +568,12 @@ sys_recvmsg(p, v, retval)
sizeof (msg));
if (error)
return (error);
- if (msg.msg_iovlen <= 0)
- return (EINVAL);
- if (msg.msg_iovlen >= UIO_SMALLIOV) {
- if (msg.msg_iovlen >= UIO_MAXIOV)
- return (EMSGSIZE);
+ if (msg.msg_iovlen <= 0 || msg.msg_iovlen > UIO_MAXIOV)
+ return (EMSGSIZE);
+ if (msg.msg_iovlen > UIO_SMALLIOV)
MALLOC(iov, struct iovec *,
sizeof(struct iovec) * msg.msg_iovlen, M_IOV, M_WAITOK);
- } else
+ else
iov = aiov;
#ifdef COMPAT_OLDSOCK
msg.msg_flags = SCARG(uap, flags) &~ MSG_COMPAT;