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

2014-01-14 Thread Stéphane Graber
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 

Good catch.

Acked-by: Stéphane Graber 

> ---
>  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


signature.asc
Description: Digital signature
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


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

2014-01-14 Thread Qiang Huang
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 
---
 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

___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel