mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +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:
parent
64405c1d5b
commit
edca5ab0af
5
sysctl.c
5
sysctl.c
@ -72,7 +72,7 @@ static int sysctl_write_##__type(int fd, \
|
|||||||
int i, ret = -1; \
|
int i, ret = -1; \
|
||||||
int off = 0; \
|
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]); \
|
snprintf(&buf[off], sizeof(buf) - off, __fmt, arg[i]); \
|
||||||
off += strlen(&buf[off]); \
|
off += strlen(&buf[off]); \
|
||||||
} \
|
} \
|
||||||
@ -87,8 +87,7 @@ static int sysctl_write_##__type(int fd, \
|
|||||||
while (off > 0 && isspace(buf[off - 1])) \
|
while (off > 0 && isspace(buf[off - 1])) \
|
||||||
off--; \
|
off--; \
|
||||||
buf[off + 0] = '\n'; \
|
buf[off + 0] = '\n'; \
|
||||||
buf[off + 1] = '\0'; \
|
ret = write(fd, buf, off + 1); \
|
||||||
ret = write(fd, buf, off + 2); \
|
|
||||||
if (ret < 0) { \
|
if (ret < 0) { \
|
||||||
pr_perror("Can't write %s", req->name); \
|
pr_perror("Can't write %s", req->name); \
|
||||||
ret = -1; \
|
ret = -1; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user