[lxc-devel] [PATCH 3/6] fix NULL dereference

Serge Hallyn serge.hallyn at ubuntu.com
Mon Apr 13 19:06:21 UTC 2015


Quoting Tycho Andersen (tycho.andersen at canonical.com):
> 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>

jikes, thank you.

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.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
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list