From 70ac9fcbf4cbec8e4d581e0b0f8b229456a5a517 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 28 Jul 1998 00:13:59 +0000 Subject: Return EINVAL when msg_iovlen or iovcnt <= 0; Make uio_resid unsigned (size_t) and don't return EINVAL if it is < 0 in sys_{read,write}. Remove check for uio_resid < 0 uiomove() now that uio_resid is unsigned and brack remaining panics with #ifdef DIAGNOSTIC. vn_rdwr() must now take a size_t * as its 9th argument so change that and clean up uses of vn_rdwr(). Fixes 549 + more --- sys/kern/sys_generic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sys/kern/sys_generic.c') diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 1603e9e4595..fb6cf718aef 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.12 1998/02/09 06:29:07 tholo Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.13 1998/07/28 00:12:58 millert Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -102,8 +102,6 @@ sys_read(p, v, retval) auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; auio.uio_procp = p; - if (auio.uio_resid < 0) - return EINVAL; #ifdef KTRACE /* * if tracing, save a copy of iovec @@ -157,6 +155,8 @@ sys_readv(p, v, retval) (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL || (fp->f_flag & FREAD) == 0) return (EBADF); + if (SCARG(uap, iovcnt) <= 0) + return (EINVAL); /* note: can't use iovlen until iovcnt is validated */ iovlen = SCARG(uap, iovcnt) * sizeof (struct iovec); if (SCARG(uap, iovcnt) > UIO_SMALLIOV) { @@ -252,8 +252,6 @@ sys_write(p, v, retval) auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; auio.uio_procp = p; - if (auio.uio_resid < 0) - return EINVAL; #ifdef KTRACE /* * if tracing, save a copy of iovec @@ -310,6 +308,8 @@ sys_writev(p, v, retval) (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL || (fp->f_flag & FWRITE) == 0) return (EBADF); + if (SCARG(uap, iovcnt) <= 0) + return (EINVAL); /* note: can't use iovlen until iovcnt is validated */ iovlen = SCARG(uap, iovcnt) * sizeof (struct iovec); if (SCARG(uap, iovcnt) > UIO_SMALLIOV) { -- cgit v1.2.3