Date: Mon, 27 Jul 2026 22:32:45 +0000 From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Olivier Certner <olce@FreeBSD.org> Subject: git: b4bd57d76563 - stable/14 - sysctl(9): Booleans: Fix old value length discovery Message-ID: <6a67dc8d.258ac.34a326ab@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b4bd57d765632abdc770ed1f7089624a9cfa666e commit b4bd57d765632abdc770ed1f7089624a9cfa666e Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2026-02-03 22:25:46 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-07-27 22:32:00 +0000 sysctl(9): Booleans: Fix old value length discovery When calling sysctl(3) with a null 'oldp', i.e., length discovery mode, 'oldix' can be equal to 'oldlen', and we should not fail. More generally, let SYSCTL_OUT() and SYSCTL_IN() handle corner cases, simply removing the comparisons between 'oldidx' and 'oldlen' and 'newidx' and 'newlen' done by hand as the test just after is an equality that does not require to know if 'idx' is smaller than 'len'. PR: 292917 Reported by: cy Fixes: 406da392ef8d ("sysctl(9): Booleans: Accept integers to ease knob conversion") Sponsored by: The FreeBSD Foundation (cherry picked from commit 895e1c6567d9561c86f8d20b47e924911bce989e) --- sys/kern/kern_sysctl.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index f65e8506abd8..b0201a6fc3e0 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1537,8 +1537,6 @@ sysctl_handle_bool(SYSCTL_HANDLER_ARGS) * the output buffer, we assume that the caller expected an 'int' * instead of a 'uint8_t'. */ - if (req->oldidx >= req->oldlen) - return (ENOMEM); if (req->oldlen - req->oldidx == sizeof(int)) { int temp_int = temp; @@ -1555,8 +1553,6 @@ sysctl_handle_bool(SYSCTL_HANDLER_ARGS) * Conversely, if the input buffer has exactly 4 bytes to read, * use them all to produce a bool. */ - if (req->newidx >= req->newlen) - return (ENOMEM); if (req->newlen - req->newidx == sizeof(int)) { int temp_int;home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a67dc8d.258ac.34a326ab>
