]> 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, 10 May 2018 18:24:49 +0000 (20:24 +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 253331160aa2d466ad10320a3af1029437094838..e854b8b0335ca056f8a6a716f3b5432502430d51 100644 (file)
@@ -4117,6 +4117,9 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
        int ret = -1, status = -1;
        char c = '1';
 
+       if (!conf)
+               return -EINVAL;
+
        idmap = get_minimal_idmap(conf);
        if (!idmap)
                return -1;
@@ -4200,6 +4203,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 30efeaff854e6991b456573384425bb600b2d258..b396a6d5aeb8e8ea1d1f9f6fee695a58e3bf55bc 100644 (file)
@@ -2955,6 +2955,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;