2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

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: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2014-08-13 17:51:04 +04:00 committed by Pavel Emelyanov
parent 64405c1d5b
commit edca5ab0af

View File

@ -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; \