]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer.c: check lxc_conf before referance haltsignal
authorQiang Huang <h.huangqiang@huawei.com>
Wed, 15 Jan 2014 02:45:18 +0000 (10:45 +0800)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 15 Jan 2014 02:52:44 +0000 (21:52 -0500)
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@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxccontainer.c

index 8462ba581ebc297897a57a775042c5a09161c689..0bebdff1b015ae060e413262bacefb8d0d22cacf 100644 (file)
@@ -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);