diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-07-28 04:29:46 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-07-28 04:29:46 +0000 |
commit | 4901110b78223c1f08ca420a604b986df751a3c9 (patch) | |
tree | 2dd31de9646016438adcf5b20cc55f825df8a24e /sys/kern | |
parent | 7948cd4feec753bd744fa3328424219d4041ca04 (diff) |
Don't assume uio_resid can go negative when detecting oflow
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_syscalls.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index e2b73cb0e66..c7fa95c9ad9 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.8 1998/07/28 00:12:56 millert Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.9 1998/07/28 04:29:45 millert Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -439,8 +439,9 @@ sendit(p, s, mp, flags, retsize) auio.uio_resid = 0; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { - if ((auio.uio_resid += iov->iov_len) < 0) + if (auio.uio_resid + iov->iov_len < auio.uio_resid) return (EINVAL); + auio.uio_resid += iov->iov_len; } if (mp->msg_name) { error = sockargs(&to, mp->msg_name, mp->msg_namelen, @@ -631,8 +632,9 @@ recvit(p, s, mp, namelenp, retsize) auio.uio_resid = 0; iov = mp->msg_iov; for (i = 0; i < mp->msg_iovlen; i++, iov++) { - if ((auio.uio_resid += iov->iov_len) < 0) + if (auio.uio_resid + iov->iov_len < auio.uio_resid) return (EINVAL); + auio.uio_resid += iov->iov_len; } #ifdef KTRACE if (KTRPOINT(p, KTR_GENIO)) { |