[lxc-devel] [lxc/master] Add return check for 'lxc_cmd_get_name'

lifeng68 on Github lxc-bot at linuxcontainers.org
Mon Jan 8 06:37:08 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 463 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180108/5ed6613c/attachment.bin>
-------------- next part --------------
From ee2d7093f0ce36773500639e52605ca3f66f2136 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68 at huawei.com>
Date: Mon, 8 Jan 2018 14:26:00 -0500
Subject: [PATCH] Add return check for 'lxc_cmd_get_name'

If 'lxc_cmd_get_name' failed and return with NULL, this would cause a segment fault.

Signed-off-by: LiFeng <lifeng68 at huawei.com>
---
 src/lxc/lxccontainer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 4a15982cb..2a4bb51f3 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -4913,6 +4913,8 @@ int list_active_containers(const char *lxcpath, char ***nret,
 			if (strncmp(lxcpath, recvpath, lxcpath_len) != 0)
 				continue;
 			p = lxc_cmd_get_name(p);
+			if (!p)
+				continue;
 		}
 
 		if (array_contains(&ct_name, p, ct_name_cnt))


More information about the lxc-devel mailing list