[hackers] [ubase] Use streplace() in setsysctl() as well || sin

From: <git_AT_suckless.org>
Date: Thu, 17 Apr 2014 20:05:54 +0200

commit 2618410910ce2c8dacdc418d3f8d96fc673d39b3
Author: sin <sin_AT_2f30.org>
Date: Thu Apr 17 19:05:25 2014 +0100

    Use streplace() in setsysctl() as well

diff --git a/sysctl.c b/sysctl.c
index 290f917..d26f9d06 100644
--- a/sysctl.c
+++ b/sysctl.c
_AT_@ -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)
Received on Thu Apr 17 2014 - 20:05:54 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 17 2014 - 20:12:14 CEST