Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jan 2021 19:40:01 GMT
From:      Ryan Moeller <freqlabs@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 65efb73fbddd - main - sbin/sysctl: Fix CTLFLAG_SKIP for adjacent nodes
Message-ID:  <202101271940.10RJe1AF037830@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by freqlabs:

URL: https://cgit.FreeBSD.org/src/commit/?id=65efb73fbddd44116fd39b03991386a67422ba6d

commit 65efb73fbddd44116fd39b03991386a67422ba6d
Author:     Ryan Moeller <freqlabs@FreeBSD.org>
AuthorDate: 2021-01-27 19:27:46 +0000
Commit:     Ryan Moeller <freqlabs@FreeBSD.org>
CommitDate: 2021-01-27 19:27:46 +0000

    sbin/sysctl: Fix CTLFLAG_SKIP for adjacent nodes
    
    The OID is saved when we encounter CTLFLAG_SKIP so that descendants can
    be skipped as well. We then must not update the skip OID until we are
    out of the node. This was achieved by resetting the skip OID once the
    prefix no longer matches, but the case where the OID we reset on has
    CTLFLAG_SKIP was not accounted for.
    
    Reported by:    mav
    Reviewed by:    mav
    MFC after:      2 days
    Sponsored by:   iXsystems, Inc.
    Differential Revision:  https://reviews.freebsd.org/D28364
---
 sbin/sysctl/sysctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index bd1e357065dc..30d6d94723fa 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1030,7 +1030,8 @@ show_var(int *oid, int nlen, bool honor_skip)
 	}
 
 	/* keep track of encountered skip nodes, ignoring descendants */
-	if (skip_len == 0 && (kind & CTLFLAG_SKIP) != 0) {
+	if ((skip_len == 0 || skip_len >= nlen * (int)sizeof(int)) &&
+	    (kind & CTLFLAG_SKIP) != 0) {
 		/* Save this oid so we can skip descendants. */
 		skip_len = nlen * sizeof(int);
 		memcpy(skip_oid, oid, skip_len);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101271940.10RJe1AF037830>