]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: avoid NULL pointer dereference
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 6 May 2017 21:38:22 +0000 (23:38 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 8 May 2017 10:15:44 +0000 (12:15 +0200)
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 <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index 3cee18ca782a2fa9c3a3957e34a2ba20d31c2291..ebbcfe86c2e3dea2d2cf3e677717fdfb04f25813 100644 (file)
@@ -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);
                }