Unverified Commit e052e6d0 by Christian Brauner Committed by Stéphane Graber

conf: don't double free in get_minimal_idmap()

Fixes: Coverity 1461725. Fixes: Coverity 1461727. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 6a40ccf5
...@@ -3951,7 +3951,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf, ...@@ -3951,7 +3951,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
euid = geteuid(); euid = geteuid();
if (euid >= container_root_uid->hostid && if (euid >= container_root_uid->hostid &&
euid < (container_root_uid->hostid + container_root_uid->range)) euid < (container_root_uid->hostid + container_root_uid->range))
host_uid_map = container_root_uid; host_uid_map = move_ptr(container_root_uid);
container_root_gid = mapped_nsid_add(conf, nsgid, ID_TYPE_GID); container_root_gid = mapped_nsid_add(conf, nsgid, ID_TYPE_GID);
if (!container_root_gid) if (!container_root_gid)
...@@ -3959,7 +3959,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf, ...@@ -3959,7 +3959,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
egid = getegid(); egid = getegid();
if (egid >= container_root_gid->hostid && if (egid >= container_root_gid->hostid &&
egid < (container_root_gid->hostid + container_root_gid->range)) egid < (container_root_gid->hostid + container_root_gid->range))
host_gid_map = container_root_gid; host_gid_map = move_ptr(container_root_gid);
/* Check whether the {g,u}id of the user has a mapping. */ /* Check whether the {g,u}id of the user has a mapping. */
if (!host_uid_map) if (!host_uid_map)
...@@ -3985,7 +3985,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf, ...@@ -3985,7 +3985,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
lxc_list_add_elem(tmplist, container_root_uid); lxc_list_add_elem(tmplist, container_root_uid);
lxc_list_add_tail(idmap, tmplist); lxc_list_add_tail(idmap, tmplist);
if (host_uid_map != container_root_uid) { if (container_root_uid) {
/* idmap will now keep track of that memory. */ /* idmap will now keep track of that memory. */
move_ptr(container_root_uid); move_ptr(container_root_uid);
...@@ -4007,7 +4007,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf, ...@@ -4007,7 +4007,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
lxc_list_add_elem(tmplist, container_root_gid); lxc_list_add_elem(tmplist, container_root_gid);
lxc_list_add_tail(idmap, tmplist); lxc_list_add_tail(idmap, tmplist);
if (host_gid_map != container_root_gid) { if (container_root_gid) {
/* idmap will now keep track of that memory. */ /* idmap will now keep track of that memory. */
move_ptr(container_root_gid); move_ptr(container_root_gid);
......
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