From: Christian Brauner Date: Tue, 1 May 2018 15:27:51 +0000 (+0200) Subject: coverity: #1425744 X-Git-Tag: lxc-2.0.10~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8053f98b976f010d9e9aae94508758df028c2695;p=thirdparty%2Flxc.git coverity: #1425744 Dereference after null check userns_exec_{1,full} are called from functions that might not have a conf. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index cbbe0bbae..09acc34a2 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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"); diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 478c7924b..5e5f2217e 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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;