ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 2618410910ce2c8dacdc418d3f8d96fc673d39b3
parent 87cb818ac027c000d491b01f9636c4a1a5e42b21
Author: sin <sin@2f30.org>
Date:   Thu Apr 17 19:05:25 +0100

Use streplace() in setsysctl() as well

Diffstat:
sysctl.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sysctl.c b/sysctl.c @@ -80,17 +80,18 @@ static int setsysctl(char *variable, char *value) { char path[PATH_MAX]; - char *p; int fd; ssize_t n; - for (p = variable; *p; p++) - if (*p == '.') - *p = '/'; + streplace(variable, '.', '/'); strlcpy(path, "/proc/sys/", sizeof(path)); - if (strlcat(path, variable, sizeof(path)) >= sizeof(path)) + if (strlcat(path, variable, sizeof(path)) >= sizeof(path)) { + streplace(variable, '/', '.'); return -1; + } + + streplace(variable, '/', '.'); fd = open(path, O_WRONLY); if (fd < 0)