#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;
}
log_debug("Setting '%s' to '%s'", property, value);
- p = new(char, sizeof("/proc/sys/") + strlen(property));
+ p = new(char, strlen("/proc/sys/") + strlen(property) + 1);
if (!p)
return log_oom();
assert(path);
- r = search_and_fopen_nulstr(path, "re", conf_file_dirs, &f);
+ r = search_and_fopen_nulstr(path, "re", NULL, conf_file_dirs, &f);
if (r < 0) {
if (ignore_enoent && r == -ENOENT)
return 0;
case ARG_PREFIX: {
char *p;
- char **l;
for (p = optarg; *p; p++)
if (*p == '.')