From f8debc846d5fdb0ef3d67c7dad7a0cdcc1091fa8 Mon Sep 17 00:00:00 2001 From: kn Date: Sat, 27 Dec 2025 22:25:31 +0000 Subject: [PATCH] Ignore whitespace-only or whitespace-then-comment lines from -f sysctl.conf " " or " # comment" would be parsed as variable name rather than skipped. Found and fixed by "Alf" on bugs@, thanks. New regress/sbin/sysctl spc and spc-com targets now pass with this. "looks good" deraadt --- sbin/sysctl/sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index a19d8872a6f..e080a0beddc 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.268 2025/08/06 16:50:53 florian Exp $ */ +/* $OpenBSD: sysctl.c,v 1.269 2025/12/27 22:25:31 kn Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -295,7 +295,7 @@ main(int argc, char *argv[]) while (getline(&line, &sz, fp) != -1) { lp = line + strspn(line, " \t"); - line[strcspn(line, " \t\n#")] = '\0'; + lp[strcspn(lp, " \t\n#")] = '\0'; if (lp[0] != '\0') parse(line, 1);