[lxc-devel] [PATCH] lxccontainer.c: check lxc_conf before referance haltsignal

Stéphane Graber stgraber at ubuntu.com
Wed Jan 15 02:51:51 UTC 2014


On Wed, Jan 15, 2014 at 10:45:18AM +0800, Qiang Huang wrote:
> If we start container with rcfile(see comments in lxc_start.c), it
> is possible that we have no config file in /usr/local/var/lib/lxc.
> So when we try lxc_stop, lxc_container_new will not load any config
> so we'll get c->lxc_conf = NULL.
> 
> In that case, we'll get Segmentation fault in lxcapi_shutdown, a
> simple check would fix this.
> 
> Signed-off-by: Qiang Huang <h.huangqiang at huawei.com>

Good catch.

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/lxccontainer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 8462ba5..0bebdff 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -1313,7 +1313,7 @@ static bool lxcapi_shutdown(struct lxc_container *c, int timeout)
>  	pid = c->init_pid(c);
>  	if (pid <= 0)
>  		return true;
> -	if (c->lxc_conf->haltsignal)
> +	if (c->lxc_conf && c->lxc_conf->haltsignal)
>  		haltsignal = c->lxc_conf->haltsignal;
>  	kill(pid, haltsignal);
>  	retv = c->wait(c, "STOPPED", timeout);
> -- 
> 1.8.3
> 

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140114/07300bb7/attachment.pgp>


More information about the lxc-devel mailing list