[lxc-devel] [lxc/master] Fix resource leak CID #1248106

simos on Github lxc-bot at linuxcontainers.org
Mon May 14 23:18:54 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 462 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180514/e40e6020/attachment.bin>
-------------- next part --------------
From 798c373c75a7b266cddb42610661f2eef5b37b5c Mon Sep 17 00:00:00 2001
From: Simos Xenitellis <simos.lists at googlemail.com>
Date: Tue, 15 May 2018 01:39:27 +0300
Subject: [PATCH 1/3] Fixed resource leak in suggest_default_idmap() @ conf.c

coverity: #1425802
coverity: #1425844
---
 src/lxc/conf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e854b8b03..22edd8cb7 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -4497,6 +4497,8 @@ void suggest_default_idmap(void)
 	if (!urange || !grange) {
 		ERROR("You do not have subuids or subgids allocated");
 		ERROR("Unprivileged containers require subuids and subgids");
+		free(gname);
+		free(uname);
 		return;
 	}
 

From ed4375f568d3527e321c628df9b04cf34bf1d34a Mon Sep 17 00:00:00 2001
From: Simos Xenitellis <simos.lists at googlemail.com>
Date: Tue, 15 May 2018 01:47:16 +0300
Subject: [PATCH 2/3] Fixed resource leak in userns_exec_full() @ conf.c

coverity: #1425836
---
 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 22edd8cb7..df07be8a0 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(id_map);
+	}
 	if (container_root_uid)
 		free(container_root_uid);
 	if (container_root_gid)

From 317c7f19cc76cea7086ccf721e808e83790f0f25 Mon Sep 17 00:00:00 2001
From: Simos Xenitellis <simos.lists at googlemail.com>
Date: Tue, 15 May 2018 01:49:41 +0300
Subject: [PATCH 3/3] Fixed resource leak in is_wlan() @ network.c

coverity: #1248106
---
 src/lxc/network.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index a7e05280d..835a1fb69 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -591,8 +591,10 @@ static char *is_wlan(const char *ifname)
 	fseek(f, 0, SEEK_END);
 	physlen = ftell(f);
 	fseek(f, 0, SEEK_SET);
-	if (physlen < 0)
+	if (physlen < 0) {
+		fclose(f);
 		goto bad;
+	}
 
 	physname = malloc(physlen + 1);
 	if (!physname) {


More information about the lxc-devel mailing list