[lxc-devel] [PATCH 3/6] fix NULL dereference
Tycho Andersen
tycho.andersen at canonical.com
Mon Apr 13 18:07:02 UTC 2015
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 at canonical.com>
---
src/lxc/lxccontainer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 6a2b080..0218e57 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;
--
2.1.4
More information about the lxc-devel
mailing list