diff options
author | marius <marius@FreeBSD.org> | 2013-02-11 21:50:00 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2013-02-11 21:50:00 +0000 |
commit | eee08c3a98e03462ab93a8d7889a96297e598e98 (patch) | |
tree | 101474f11141b4cd320a1b681fc407daae17a5e1 | |
parent | 2f7fb4d40e5c8946234b6c634d8361dc7202bd74 (diff) | |
download | FreeBSD-src-eee08c3a98e03462ab93a8d7889a96297e598e98.zip FreeBSD-src-eee08c3a98e03462ab93a8d7889a96297e598e98.tar.gz |
Make SYSCTL_{LONG,QUAD,ULONG,UQUAD}(9) work as advertised and also handle
constant values.
Reviewed by: kib
MFC after: 3 days
-rw-r--r-- | sys/kern/kern_sysctl.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index f294ce3..521714c 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); } |