diff options
Diffstat (limited to 'src/sysctl/sysctl.c')
-rw-r--r-- | src/sysctl/sysctl.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 283eefe1a1..06defa5b7c 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -48,12 +48,26 @@ static const char conf_file_dirs[] = #endif ; -static char *normalize_sysctl(char *s) { +static char* normalize_sysctl(char *s) { char *n; - for (n = s; *n; n++) + n = strpbrk(s, "/."); + /* If the first separator is a slash, the path is + * assumed to be normalized and slashes remain slashes + * and dots remains dots. */ + if (!n || *n == '/') + return s; + + /* Otherwise, dots become slashes and slashes become + * dots. Fun. */ + while (n) { if (*n == '.') *n = '/'; + else + *n = '.'; + + n = strpbrk(n + 1, "/."); + } return s; } |