From: Christian Brauner Date: Sat, 6 May 2017 21:38:22 +0000 (+0200) Subject: lxccontainer: avoid NULL pointer dereference X-Git-Tag: lxc-2.1.0~141^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=899a9f554500ad56e120302f94a0134f2e2c2354;p=thirdparty%2Flxc.git lxccontainer: avoid NULL pointer dereference In case the lxc command socket is hashed and the socket was created for a different path than the one we're currently querying lxc_cmd_get_{lxcpath,name}() can return NULL. The command socket path is hashed when len(lxcpath) > sizeof(sun_path) - 2. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 3cee18ca7..ebbcfe86c 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -4370,7 +4370,10 @@ int list_active_containers(const char *lxcpath, char ***nret, *p2 = '\0'; if (is_hashed) { - if (strncmp(lxcpath, lxc_cmd_get_lxcpath(p), lxcpath_len) != 0) + char *recvpath = lxc_cmd_get_lxcpath(p); + if (!recvpath) + continue; + if (strncmp(lxcpath, recvpath, lxcpath_len) != 0) continue; p = lxc_cmd_get_name(p); }