aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2013-02-11 21:50:00 +0000
committerMarius Strobl <marius@FreeBSD.org>2013-02-11 21:50:00 +0000
commitbdc5f0172eddb31fe7ec682e203de544d08472e1 (patch)
tree101474f11141b4cd320a1b681fc407daae17a5e1 /sys/kern/kern_sysctl.c
parent6a33bbc041ba90cd6dee1dcb2258e5be9c35513a (diff)
downloadsrc-bdc5f0172eddb31fe7ec682e203de544d08472e1.tar.gz
src-bdc5f0172eddb31fe7ec682e203de544d08472e1.zip
Make SYSCTL_{LONG,QUAD,ULONG,UQUAD}(9) work as advertised and also handle
constant values. Reviewed by: kib MFC after: 3 days
Notes
Notes: svn path=/head/; revision=246689
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index f294ce3b9a87..521714c57415 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1051,9 +1051,10 @@ sysctl_handle_long(SYSCTL_HANDLER_ARGS)
/*
* Attempt to get a coherent snapshot by making a copy of the data.
*/
- if (!arg1)
- return (EINVAL);
- tmplong = *(long *)arg1;
+ if (arg1)
+ tmplong = *(long *)arg1;
+ else
+ tmplong = arg2;
#ifdef SCTL_MASK32
if (req->flags & SCTL_MASK32) {
tmpint = tmplong;
@@ -1065,12 +1066,15 @@ sysctl_handle_long(SYSCTL_HANDLER_ARGS)
if (error || !req->newptr)
return (error);
+ if (!arg1)
+ error = EPERM;
#ifdef SCTL_MASK32
- if (req->flags & SCTL_MASK32) {
+ else if (req->flags & SCTL_MASK32) {
error = SYSCTL_IN(req, &tmpint, sizeof(int));
*(long *)arg1 = (long)tmpint;
- } else
+ }
#endif
+ else
error = SYSCTL_IN(req, arg1, sizeof(long));
return (error);
}
@@ -1087,15 +1091,19 @@ sysctl_handle_64(SYSCTL_HANDLER_ARGS)
/*
* Attempt to get a coherent snapshot by making a copy of the data.
*/
- if (!arg1)
- return (EINVAL);
- tmpout = *(uint64_t *)arg1;
+ if (arg1)
+ tmpout = *(uint64_t *)arg1;
+ else
+ tmpout = arg2;
error = SYSCTL_OUT(req, &tmpout, sizeof(uint64_t));
if (error || !req->newptr)
return (error);
- error = SYSCTL_IN(req, arg1, sizeof(uint64_t));
+ if (!arg1)
+ error = EPERM;
+ else
+ error = SYSCTL_IN(req, arg1, sizeof(uint64_t));
return (error);
}