Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Set *sizep correctly if returning the number of ele...
details: https://anonhg.NetBSD.org/src/rev/33c224f99509
branches: trunk
changeset: 486642:33c224f99509
user: simonb <simonb%NetBSD.org@localhost>
date: Sat May 27 03:24:50 2000 +0000
description:
Set *sizep correctly if returning the number of elements. Pointed out
by Anders Magnusson.
Honor elem_count in the KERN_PROC2 case, as well as overall buffer
space. The only user-land code to use this set the elem_count to
"buffer_space / elem_size", so we've had no incorrect behaviour to date.
diffstat:
sys/kern/kern_sysctl.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (35 lines):
diff -r 970d9c3f6034 -r 33c224f99509 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c Sat May 27 03:23:22 2000 +0000
+++ b/sys/kern/kern_sysctl.c Sat May 27 03:24:50 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.63 2000/05/26 22:59:31 thorpej Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.64 2000/05/27 03:24:50 simonb Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -1069,7 +1069,7 @@
}
needed += sizeof(struct kinfo_proc);
} else { /* KERN_PROC2 */
- if (buflen >= elem_size) {
+ if (buflen >= elem_size && elem_count > 0) {
fill_kproc2(p, &kproc2);
/*
* Copy out elem_size, but not larger than
@@ -1081,6 +1081,7 @@
goto cleanup;
dp2 += elem_size;
buflen -= elem_size;
+ elem_count--;
}
needed += elem_size;
}
@@ -1417,7 +1418,7 @@
memcpy(&nargv, (char *)&pss + p->p_psnenv, sizeof(nargv));
if (type == KERN_PROC_NARGV || type == KERN_PROC_NENV) {
error = copyout(&nargv, where, sizeof(nargv));
- *sizep = len;
+ *sizep = sizeof(nargv);
goto done;
}
/*
Home |
Main Index |
Thread Index |
Old Index