Commit fb4f28f0 authored by Andrei Vagin's avatar Andrei Vagin Committed by Pavel Emelyanov

proc_parse: use the static buffer to parse mountinfo

Currently a buffer is allocated on stack and its size is 1024.
Usually we use our static buffer to read proc files and its
size is 4096 (page size).

I know that this patch doesn't fix this problem completly,
it just does it less critical.

https://github.com/opencontainers/runc/issues/1070
travis-ci: success for proc_parse: use the static buffer to parse mountinfo
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 11adfc34
......@@ -1410,7 +1410,6 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
{
struct mount_info *list = NULL;
FILE *f;
char str[1024];
f = fopen_proc(pid, "mountinfo");
if (!f) {
......@@ -1418,7 +1417,7 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
return NULL;
}
while (fgets(str, sizeof(str), f)) {
while (fgets(buf, BUF_SIZE, f)) {
struct mount_info *new;
int ret = -1;
char *fsname = NULL;
......@@ -1429,9 +1428,9 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
new->nsid = nsid;
ret = parse_mountinfo_ent(str, new, &fsname);
ret = parse_mountinfo_ent(buf, new, &fsname);
if (ret < 0) {
pr_err("Bad format in %d mountinfo: '%s'\n", pid, str);
pr_err("Bad format in %d mountinfo: '%s'\n", pid, buf);
goto end;
}
......
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