diff options
author | 1998-07-28 04:29:45 +0000 | |
---|---|---|
committer | 1998-07-28 04:29:45 +0000 | |
commit | 0af5ed14da8eb4fc915b02e12adf242d0bc3c0e9 (patch) | |
tree | 06152b258ba3669771a87245357bc4519dcf665b | |
parent | Don't talk about the sum of the iov_len being negative since iov_len is unsigned. (diff) | |
download | wireguard-openbsd-0af5ed14da8eb4fc915b02e12adf242d0bc3c0e9.tar.xz wireguard-openbsd-0af5ed14da8eb4fc915b02e12adf242d0bc3c0e9.zip |
Don't assume uio_resid can go negative when detecting oflow
-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)) { |