]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425744
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 May 2018 15:27:51 +0000 (17:27 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Aug 2018 21:12:21 +0000 (23:12 +0200)
Dereference after null check

userns_exec_{1,full} are called from functions that might not have a conf.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/lxccontainer.c

index cbbe0bbae348c09103b8bbb4b0b5ba10de544f90..09acc34a257a677fa58bb5b6992311ca32478527 100644 (file)
@@ -3815,6 +3815,9 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
        int ret = -1, status = -1;
        struct lxc_list *idmap;
 
+       if (!conf)
+               return -EINVAL;
+
        idmap = get_minimal_idmap(conf);
        if (!idmap)
                return -1;
@@ -3898,6 +3901,9 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
        struct id_map *container_root_uid = NULL, *container_root_gid = NULL,
                      *host_uid_map = NULL, *host_gid_map = NULL;
 
+       if (!conf)
+               return -EINVAL;
+
        ret = pipe(p);
        if (ret < 0) {
                SYSERROR("opening pipe");
index 478c7924bb7e65c9226c62dda82b5519ee8c8b99..5e5f2217e6ef4373e807a138e8ec6d6cadc68747 100644 (file)
@@ -2698,6 +2698,7 @@ static bool do_lxcapi_destroy(struct lxc_container *c)
 {
        if (!c || !lxcapi_is_defined(c))
                return false;
+
        if (has_snapshots(c)) {
                ERROR("Container %s has snapshots;  not removing", c->name);
                return false;