From: Tycho Andersen Date: Mon, 13 Apr 2015 18:07:02 +0000 (+0000) Subject: fix NULL dereference X-Git-Tag: lxc-2.0.0.beta1~314 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcd1e262744cd37f054264254a7e1472255e6936;p=thirdparty%2Flxc.git fix NULL dereference 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 Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 6a2b08057..0218e57bc 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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;