summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-02-11 12:34:31 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-02-11 12:34:31 +0000
commit62367e1b2d97f43999f11bd72a476b66c2f286b4 (patch)
treef2cc75f9684c8abd8c077c7187602092969e2e93 /sys/kern
parent0a4863a085f8cbf484b5c6d2f27bb0fba389c8a0 (diff)
In {send,recv}msg allow zero sized message. We can have control data.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_syscalls.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 83f7283e09e..7d314949914 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.48 2002/02/08 13:53:28 art Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.49 2002/02/11 12:34:30 art Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -429,7 +429,7 @@ sys_sendmsg(p, v, retval)
error = copyin(SCARG(uap, msg), (caddr_t)&msg, sizeof (msg));
if (error)
return (error);
- if (msg.msg_iovlen <= 0 || msg.msg_iovlen > IOV_MAX)
+ if (msg.msg_iovlen < 0 || msg.msg_iovlen > IOV_MAX)
return (EMSGSIZE);
if (msg.msg_iovlen > UIO_SMALLIOV)
iov = malloc(sizeof(struct iovec) * msg.msg_iovlen,
@@ -600,13 +600,13 @@ sys_recvmsg(p, v, retval)
} */ *uap = v;
struct msghdr msg;
struct iovec aiov[UIO_SMALLIOV], *uiov, *iov;
- register int error;
+ int error;
error = copyin((caddr_t)SCARG(uap, msg), (caddr_t)&msg,
sizeof (msg));
if (error)
return (error);
- if (msg.msg_iovlen <= 0 || msg.msg_iovlen > IOV_MAX)
+ if (msg.msg_iovlen < 0 || msg.msg_iovlen > IOV_MAX)
return (EMSGSIZE);
if (msg.msg_iovlen > UIO_SMALLIOV)
iov = malloc(sizeof(struct iovec) * msg.msg_iovlen,
@@ -618,12 +618,14 @@ sys_recvmsg(p, v, retval)
#else
msg.msg_flags = SCARG(uap, flags);
#endif
+ if (msg.msg_iovlen > 0) {
+ error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
+ if (error)
+ goto done;
+ }
uiov = msg.msg_iov;
msg.msg_iov = iov;
- error = copyin((caddr_t)uiov, (caddr_t)iov,
- (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
- if (error)
- goto done;
if ((error = recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval)) == 0) {
msg.msg_iov = uiov;
error = copyout((caddr_t)&msg, (caddr_t)SCARG(uap, msg),