mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 17:49:13 +00:00
proc_parse: Preallocate extra space for possible option string growth
The logic in sb_opt_cb converts uid and gid to using userns map, it
means that the option string can extend. Worse case we had original id
"0" and got INVALID_ID ("4294967295") back.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
14d77e316e
commit
9c4830a991
1 changed files with 7 additions and 1 deletions
|
|
@ -1547,7 +1547,13 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
|
|||
|
||||
new->fstype = find_fstype_by_name(*fsname);
|
||||
|
||||
new->options = xmalloc(strlen(opt) + 1);
|
||||
/*
|
||||
* sb_opt_cb() may translate uid=/gid= values via userns mappings,
|
||||
* producing longer decimal strings than the original. Let's
|
||||
* reserve extra space for the worst-case expansion of both a uid=
|
||||
* and a gid= value to 10-digit numbers.
|
||||
*/
|
||||
new->options = xmalloc(strlen(opt) + 1 + 2 * (sizeof("4294967295") - 1));
|
||||
if (!new->options)
|
||||
goto err;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue