提交 41fa653f 编写于 作者: R Ryota Ozaki 提交者: Daniel Veillard

LXC fix virCgroupGetValueStr problem with \n

A cgroup file returns integer value terminated with '\n' and remaining
it has sometimes harmful effects, for example it leads virStrToLong_ull
to fail.
* src/util/cgroup.c: strip out terminating \n when reading a value
上级 4f4a1dec
......@@ -309,6 +309,10 @@ static int virCgroupGetValueStr(virCgroupPtr group,
DEBUG("Failed to read %s: %m\n", keypath);
rc = -errno;
} else {
/* Terminated with '\n' has sometimes harmful effects to the caller */
char *p = strchr(*value, '\n');
if (p) *p = '\0';
rc = 0;
}
......@@ -969,13 +973,7 @@ int virCgroupSetFreezerState(virCgroupPtr group, const char *state)
int virCgroupGetFreezerState(virCgroupPtr group, char **state)
{
int ret;
ret = virCgroupGetValueStr(group,
return virCgroupGetValueStr(group,
VIR_CGROUP_CONTROLLER_CPU,
"freezer.state", state);
if (ret == 0) {
char *p = strchr(*state, '\n');
if (p) *p = '\0';
}
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册