diff options
| author | 2004-05-05 23:52:09 +0000 | |
|---|---|---|
| committer | 2004-05-05 23:52:09 +0000 | |
| commit | 9aeeba8da64d5e1f800a55af35dc030bc729b6d6 (patch) | |
| tree | cc1c3fe63cb5eef66948e7e76f515ea0cf7758c6 /sys/miscfs/procfs/procfs_linux.c | |
| parent | better cleandir (diff) | |
| download | wireguard-openbsd-9aeeba8da64d5e1f800a55af35dc030bc729b6d6.tar.xz wireguard-openbsd-9aeeba8da64d5e1f800a55af35dc030bc729b6d6.zip | |
make sure uio_offset is a safe value, with suggestions from millert@
ok deraadt@ millert@
problem noticed by deprotect.com
Diffstat (limited to 'sys/miscfs/procfs/procfs_linux.c')
| -rw-r--r-- | sys/miscfs/procfs/procfs_linux.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/miscfs/procfs/procfs_linux.c b/sys/miscfs/procfs/procfs_linux.c index fe3072d3ac4..356a173d8aa 100644 --- a/sys/miscfs/procfs/procfs_linux.c +++ b/sys/miscfs/procfs/procfs_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_linux.c,v 1.4 2001/11/06 19:53:20 miod Exp $ */ +/* $OpenBSD: procfs_linux.c,v 1.5 2004/05/05 23:52:10 tedu Exp $ */ /* $NetBSD: procfs_linux.c,v 1.2.4.1 2001/03/30 21:48:11 he Exp $ */ /* @@ -89,16 +89,13 @@ procfs_domeminfo(struct proc *curp, struct proc *p, struct pfsnode *pfs, PGTOKB(uvmexp.swpages), PGTOKB(uvmexp.swpages - uvmexp.swpginuse)); - if (len == 0) + if (len == 0 || len <= uio->uio_offset || uio->uio_resid == 0) return 0; len -= uio->uio_offset; cp = buf + uio->uio_offset; len = imin(len, uio->uio_resid); - if (len <= 0) - error = 0; - else - error = uiomove(cp, len, uio); + error = uiomove(cp, len, uio); return error; } @@ -113,7 +110,7 @@ procfs_docpuinfo(struct proc *curp, struct proc *p, struct pfsnode *pfs, if (procfs_getcpuinfstr(buf, &len) < 0) return EIO; - if (len == 0) + if (len == 0 || uio->uio_offset > sizeof(buf)) return 0; len -= uio->uio_offset; |
