summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-02-14 19:02:22 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-02-14 19:02:22 +0000
commitd3c057cb213552b36fc591abb64e7530d6006909 (patch)
treee69ef54a69406e430ac355e5ae39f5c243ce67e2 /sys/kern/uipc_syscalls.c
parent2cf9841a6d96670b5f8710f70da153060f3ba3d3 (diff)
readv/writev with iov_len == 0 is legal (was already ok in uipc_syscalls.c).
Make the check more readable by comparing against SSIZE_MAX instead of checking for wraparound. This is safe because SSIZE_MAX * 2 <= SIZE_T_MAX. Fixes recno problems in the db routines exposed by a perl test.
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r--sys/kern/uipc_syscalls.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 7aab5433a8b..ee626a84ba1 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.14 1999/02/11 05:33:09 deraadt Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.15 1999/02/14 19:02:20 millert Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -439,8 +439,8 @@ sendit(p, s, mp, flags, retsize)
iov = mp->msg_iov;
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
/* Don't allow sum > SSIZE_MAX */
- if ((ssize_t)(auio.uio_resid += iov->iov_len) <= 0 &&
- (iov->iov_base != 0 || iov->iov_len != 0))
+ if (iov->iov_len > SSIZE_MAX ||
+ (auio.uio_resid += iov->iov_len) > SSIZE_MAX)
return (EINVAL);
}
if (mp->msg_name) {
@@ -630,8 +630,8 @@ recvit(p, s, mp, namelenp, retsize)
iov = mp->msg_iov;
for (i = 0; i < mp->msg_iovlen; i++, iov++) {
/* Don't allow sum > SSIZE_MAX */
- if ((ssize_t)(auio.uio_resid += iov->iov_len) <= 0 &&
- (iov->iov_base != 0 || iov->iov_len != 0))
+ if (iov->iov_len > SSIZE_MAX ||
+ (auio.uio_resid += iov->iov_len) > SSIZE_MAX)
return (EINVAL);
}
#ifdef KTRACE