]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
fix NULL dereference
authorTycho Andersen <tycho.andersen@canonical.com>
Mon, 13 Apr 2015 18:07:02 +0000 (18:07 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 13 Apr 2015 21:58:47 +0000 (16:58 -0500)
lxc_console dereferences C, so we should check that it is not null and fail if
it is.

Reported-by: Coverity
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxccontainer.c

index f6ec587ee7e25a6cc533de822b701b4b6dc5d3ca..5ec1eec79b1b65a8409dea7b9b42eeae687d1442 100644 (file)
@@ -463,7 +463,11 @@ static int lxcapi_console(struct lxc_container *c, int ttynum, int stdinfd,
 {
        int ret;
        struct lxc_conf *old = current_config;
-       current_config = c ? c->lxc_conf : NULL;
+
+       if (!c)
+               return -1;
+
+       current_config = c->lxc_conf;
        ret = lxc_console(c, ttynum, stdinfd, stdoutfd, stderrfd, escape);
        current_config = old;
        return ret;