[lxc-devel] [lxc/master] network: fix socket handle leak

2xsec on Github lxc-bot at linuxcontainers.org
Mon May 28 05:24:02 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 473 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180528/bdb12466/attachment.bin>
-------------- next part --------------
From 87c6e5db2a792fce7aab841d5880e5e22e63eb7d Mon Sep 17 00:00:00 2001
From: Donghwa Jeong <dh48.jeong at samsung.com>
Date: Mon, 28 May 2018 13:42:45 +0900
Subject: [PATCH] network: fix socket handle leak

Signed-off-by: Donghwa Jeong <dh48.jeong at samsung.com>
---
 src/lxc/network.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 src/lxc/network.c

diff --git a/src/lxc/network.c b/src/lxc/network.c
old mode 100644
new mode 100755
index 88a1fa2ce..b6aaa4621
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -2027,8 +2027,10 @@ int setup_private_host_hw_addr(char *veth1)
 		return -errno;
 
 	err = snprintf((char *)ifr.ifr_name, IFNAMSIZ, "%s", veth1);
-	if (err < 0 || (size_t)err >= IFNAMSIZ)
+	if (err < 0 || (size_t)err >= IFNAMSIZ) {
+		close(sockfd);
 		return -E2BIG;
+	}
 
 	err = ioctl(sockfd, SIOCGIFHWADDR, &ifr);
 	if (err < 0) {


More information about the lxc-devel mailing list