]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc: Don't crash if no security driver is specified in libvirt_lxc
authorPeter Krempa <pkrempa@redhat.com>
Mon, 26 Nov 2012 14:17:58 +0000 (15:17 +0100)
committerCole Robinson <crobinso@redhat.com>
Sun, 9 Dec 2012 21:35:57 +0000 (16:35 -0500)
When no security driver is specified libvirt_lxc segfaults as a debug
message tries to access security labels for the container that are not
present.

This problem was introduced in commit 6c3cf57d6cb27cf10064baf8cca0f39.
(cherry picked from commit 99a388e612d82a6bcd3462e4b98463fb32931520)

src/lxc/lxc_controller.c

index 2807f3559a86e44595eaacfeb433cf9d33375c0d..149333284121df8ca6714cf626989a60616fd7d0 100644 (file)
@@ -1589,11 +1589,15 @@ int main(int argc, char *argv[])
                                                         false, false, false)))
         goto cleanup;
 
-    VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
-              NULLSTR(ctrl->def->seclabels[0]->model),
-              virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type),
-              NULLSTR(ctrl->def->seclabels[0]->label),
-              NULLSTR(ctrl->def->seclabels[0]->imagelabel));
+    if (ctrl->def->seclabels) {
+        VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
+                  NULLSTR(ctrl->def->seclabels[0]->model),
+                  virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type),
+                  NULLSTR(ctrl->def->seclabels[0]->label),
+                  NULLSTR(ctrl->def->seclabels[0]->imagelabel));
+    } else {
+        VIR_DEBUG("Security model not initialized");
+    }
 
     ctrl->veths = veths;
     ctrl->nveths = nveths;