Use streplace() in setsysctl() as well
This commit is contained in:
parent
87cb818ac0
commit
2618410910
11
sysctl.c
11
sysctl.c
@ -80,17 +80,18 @@ static int
|
|||||||
setsysctl(char *variable, char *value)
|
setsysctl(char *variable, char *value)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char *p;
|
|
||||||
int fd;
|
int fd;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
for (p = variable; *p; p++)
|
streplace(variable, '.', '/');
|
||||||
if (*p == '.')
|
|
||||||
*p = '/';
|
|
||||||
|
|
||||||
strlcpy(path, "/proc/sys/", sizeof(path));
|
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;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
streplace(variable, '/', '.');
|
||||||
|
|
||||||
fd = open(path, O_WRONLY);
|
fd = open(path, O_WRONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user