]> 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:54:45 +0000 (16:54 -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 6a2b080574266d074cf8a76ebb5089a37cbc2f80..0218e57bc1e6ab2918b5a7347166f7f70a3fb569 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;