The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2323

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
In function userns_exec_full() @ conf.c, there is the following
pointer that is used in a double-linked list, struct lxc_list *idmap = NULL;

This pointer is malloc()-ed, and then additional objects are added to
the list using lxc_list_add_tail().
At the end of the function, the dynamically allocated memory is freed with lxc_free_idmap(idmap);

lxc_free_idmap(idmap) does not free memory of the initial memory
allocation for "idmap", therefore there is a memory leak.

The function lxc_free_idmap() is used in another place as well, and at
that place it does not free() the initial pointer (correct behaviour).
Therefore, there is a need for a free() in the function
userns_exec_full() @ conf.c.
From d3ee1995937641fa793163faaf6c3459e92af872 Mon Sep 17 00:00:00 2001
From: Simos Xenitellis <simos.li...@googlemail.com>
Date: Tue, 15 May 2018 00:19:12 +0000
Subject: [PATCH] Fixed resource leak in userns_exec_full()

coverity: #1425836

Signed-off-by: Simos Xenitellis <simos.li...@googlemail.com>
---
 src/lxc/conf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e854b8b03..48f4fef38 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -4082,8 +4082,10 @@ struct lxc_list *get_minimal_idmap(struct lxc_conf *conf)
        return idmap;
 
 on_error:
-       if (idmap)
+       if (idmap) {
                lxc_free_idmap(idmap);
+               free(idmap);
+       }
        if (container_root_uid)
                free(container_root_uid);
        if (container_root_gid)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to