Commit b0227444 by Qiang Huang Committed by Stéphane Graber

lxccontainer.c: check lxc_conf before referance haltsignal

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: 's avatarQiang Huang <h.huangqiang@huawei.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 3139aead
...@@ -1313,7 +1313,7 @@ static bool lxcapi_shutdown(struct lxc_container *c, int timeout) ...@@ -1313,7 +1313,7 @@ static bool lxcapi_shutdown(struct lxc_container *c, int timeout)
pid = c->init_pid(c); pid = c->init_pid(c);
if (pid <= 0) if (pid <= 0)
return true; return true;
if (c->lxc_conf->haltsignal) if (c->lxc_conf && c->lxc_conf->haltsignal)
haltsignal = c->lxc_conf->haltsignal; haltsignal = c->lxc_conf->haltsignal;
kill(pid, haltsignal); kill(pid, haltsignal);
retv = c->wait(c, "STOPPED", timeout); retv = c->wait(c, "STOPPED", timeout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment