X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsysctl%2Fsysctl.c;h=06defa5b7cdf69c567a360f16fd0fbe4ccddf44d;hb=2e573fcf8754fdfe0db0a783b1631ec1679b063a;hp=283eefe1a1d233e49786034668d64c80cbe507f6;hpb=f8294e4175918117ca6c131720bcf287eadcd029;p=elogind.git diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 283eefe1a..06defa5b7 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; }