[lxc-devel] [lxc/master] coverity

brauner on Github lxc-bot at linuxcontainers.org
Tue May 15 10:40:14 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180515/c1034b87/attachment.bin>
-------------- next part --------------
From 42cc40833c6a0e3ac01006c4ed35fb73ea958a93 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 15 May 2018 12:33:22 +0200
Subject: [PATCH 1/3] coverity: #1435604

Resource leak

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 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..c77f8c7ce 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -1916,8 +1916,10 @@ int lxc_bridge_attach(const char *bridge, const char *ifname)
 		return -errno;
 
 	retlen = strlcpy(ifr.ifr_name, bridge, IFNAMSIZ);
-	if (retlen >= IFNAMSIZ)
+	if (retlen >= IFNAMSIZ) {
+		close(fd);
 		return -E2BIG;
+	}
 
 	ifr.ifr_name[IFNAMSIZ - 1] = '\0';
 	ifr.ifr_ifindex = index;

From eb091d0094d430d6d1d2b9ad5260dd41fc0177cc Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 15 May 2018 12:34:24 +0200
Subject: [PATCH 2/3] coverity: #1435603

Resource leak

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/storage/btrfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lxc/storage/btrfs.c b/src/lxc/storage/btrfs.c
index 955b6a7b2..a9ab7988a 100644
--- a/src/lxc/storage/btrfs.c
+++ b/src/lxc/storage/btrfs.c
@@ -533,6 +533,7 @@ static int btrfs_do_destroy_subvol(const char *path)
 	retlen = strlcpy(args.name, p+1, BTRFS_SUBVOL_NAME_MAX);
 	if (retlen >= BTRFS_SUBVOL_NAME_MAX) {
 		free(newfull);
+		close(fd);
 		return -E2BIG;
 	}
 

From 4b812aca236191cb86d18108102f750d9cd28c7f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 15 May 2018 12:35:34 +0200
Subject: [PATCH 3/3] coverity: #1435602

Resource leak

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/storage/btrfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lxc/storage/btrfs.c b/src/lxc/storage/btrfs.c
index a9ab7988a..be07aeb6f 100644
--- a/src/lxc/storage/btrfs.c
+++ b/src/lxc/storage/btrfs.c
@@ -254,8 +254,11 @@ static int btrfs_subvolume_create(const char *path)
 
 	memset(&args, 0, sizeof(args));
 	retlen = strlcpy(args.name, p + 1, BTRFS_SUBVOL_NAME_MAX);
-	if (retlen >= BTRFS_SUBVOL_NAME_MAX)
+	if (retlen >= BTRFS_SUBVOL_NAME_MAX) {
+		free(newfull);
+		close(fd);
 		return -E2BIG;
+	}
 
 	ret = ioctl(fd, BTRFS_IOC_SUBVOL_CREATE, &args);
 	saved_errno = errno;


More information about the lxc-devel mailing list