Hello,

I noticed that some of our machines spit the following while booting:

sysctl: top level name  in  is invalid

which can be caused by a sysctl.conf like this:

$ cat sysctl.conf
#kern.splassert=2               # 2=Enable with verbose error messages
kern.nosuidcoredump=2           # 2=Put suid coredumps in /var/crash
                                # bla bla
#kern.watchdog.period=32        # >0=Enable hardware watchdog(4) timer if 
available

The '#bla bla' line is causing the error.

The following patch fixes it for me.


Alf

(originally sent to florian@ roughly a week ago but he appears to be busy)

Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.268
diff -u -p -r1.268 sysctl.c
--- sbin/sysctl/sysctl.c        6 Aug 2025 16:50:53 -0000       1.268
+++ sbin/sysctl/sysctl.c        2 Dec 2025 09:42:15 -0000
@@ -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);


Reply via email to