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:
Pavel Tikhomirov 2026-03-26 18:09:39 +01:00 committed by Alexander Mikhalitsyn
parent 14d77e316e
commit 9c4830a991
No known key found for this signature in database
GPG key ID: B1F47F5CB05B4FA3

View file

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