Commit edca5ab0 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

sysctl: don't write '\0' at the end of buffer in a sysctl file

It isn't required. The kernel has a bug in handling auto_msgmni and
if we send extra symbols, a new value isn't applied.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 64405c1d
......@@ -72,7 +72,7 @@ static int sysctl_write_##__type(int fd, \
int i, ret = -1; \
int off = 0; \
\
for (i = 0; i < nr && off < sizeof(buf) - 2; i++) { \
for (i = 0; i < nr && off < sizeof(buf) - 1; i++) { \
snprintf(&buf[off], sizeof(buf) - off, __fmt, arg[i]); \
off += strlen(&buf[off]); \
} \
......@@ -87,8 +87,7 @@ static int sysctl_write_##__type(int fd, \
while (off > 0 && isspace(buf[off - 1])) \
off--; \
buf[off + 0] = '\n'; \
buf[off + 1] = '\0'; \
ret = write(fd, buf, off + 2); \
ret = write(fd, buf, off + 1); \
if (ret < 0) { \
pr_perror("Can't write %s", req->name); \
ret = -1; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment