Re: sysctl: Fixing "second level name in XX. is invalid" on trailing period

2023-08-29 Thread Ingo Schwarze
Hi Neel, Neel Chauhan wrote on Tue, Aug 29, 2023 at 02:36:57PM -0700: > On 2023-08-29 14:23, Theo Buehler wrote: >> Neel Chauhan: >>> + if (string[strlen(string) - 1] == '.') >>> + buf[strlen(string) - 1] = '\0'; >> Careful with out-of-bounds accesses. What if string is "" ? Probably

Re: sysctl: Fixing "second level name in XX. is invalid" on trailing period

2023-08-29 Thread Neel Chauhan
On 2023-08-29 14:23, Theo Buehler wrote: + if (string[strlen(string) - 1] == '.') + buf[strlen(string) - 1] = '\0'; Careful with out-of-bounds accesses. What if string is "" ? Probably easiest to do "len = strlen(string);" and if (len > 0 && ...). Good catch! Does this lo

Re: sysctl: Fixing "second level name in XX. is invalid" on trailing period

2023-08-29 Thread Theo Buehler
> + if (string[strlen(string) - 1] == '.') > + buf[strlen(string) - 1] = '\0'; Careful with out-of-bounds accesses. What if string is "" ? Probably easiest to do "len = strlen(string);" and if (len > 0 && ...).

sysctl: Fixing "second level name in XX. is invalid" on trailing period

2023-08-29 Thread Neel Chauhan
Hi, I don't know if this is a big issue for you, but when doing a `sysctl` call with a trailing period ("."), like `sysctl kern.`, I get an error like this: sysctl: second level name in kern. is invalid On other systems, if I do `sysctl XX.`, I get all the entries inside XX. We should fix it