summaryrefslogtreecommitdiff
path: root/sys/miscfs/procfs/procfs_status.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-05-05 23:52:11 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-05-05 23:52:11 +0000
commitc7bd171a110dc759928d58a928869b7e355969c2 (patch)
treeee7900fd3f27674c3f98e4cc4b2038b8fc2c7fe1 /sys/miscfs/procfs/procfs_status.c
parent9fa54860a762e0b9de75773b73d02d619703f634 (diff)
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_status.c')
-rw-r--r--sys/miscfs/procfs/procfs_status.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/miscfs/procfs/procfs_status.c b/sys/miscfs/procfs/procfs_status.c
index 5fb379cd861..0d1a117ffc0 100644
--- a/sys/miscfs/procfs/procfs_status.c
+++ b/sys/miscfs/procfs/procfs_status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procfs_status.c,v 1.7 2004/03/03 06:28:12 tedu Exp $ */
+/* $OpenBSD: procfs_status.c,v 1.8 2004/05/05 23:52:10 tedu Exp $ */
/* $NetBSD: procfs_status.c,v 1.11 1996/03/16 23:52:50 christos Exp $ */
/*
@@ -165,16 +165,16 @@ procfs_dostatus(curp, p, pfs, uio)
len = procfs_stat_gen(p, NULL, 0);
ps = malloc(len, M_TEMP, M_WAITOK);
- (void) procfs_stat_gen(p, ps, len);
+ len = procfs_stat_gen(p, ps, len);
- len -= uio->uio_offset;
- len = imin(len, uio->uio_resid);
- if (len <= 0)
+ if (len <= uio->uio_offset)
error = 0;
- else
+ else {
+ len -= uio->uio_offset;
+ len = imin(len, uio->uio_resid);
error = uiomove(ps + uio->uio_offset, len, uio);
+ }
free(ps, M_TEMP);
return (error);
}
-