]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
security_dac: Avoid segfault when no label is requested
authorPeter Krempa <pkrempa@redhat.com>
Tue, 28 Aug 2012 16:27:31 +0000 (18:27 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 28 Aug 2012 16:40:36 +0000 (18:40 +0200)
When no DAC "label" was requested for a domain the DAC manager tried to
strdup a NULL string causing a segfault.

src/security/security_dac.c

index 925498fe4cb9d21e3c59ddba7095a1f33eb732b8..4162e26b7e68f3b1e6f0f11370fa1bce6840c945 100644 (file)
@@ -890,6 +890,7 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr,
         break;
     case VIR_DOMAIN_SECLABEL_NONE:
         /* no op */
+        return 0;
         break;
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -899,7 +900,7 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr,
     }
 
     if (!seclabel->norelabel) {
-        if (seclabel->imagelabel == NULL) {
+        if (seclabel->imagelabel == NULL && seclabel->label != NULL) {
             seclabel->imagelabel = strdup(seclabel->label);
             if (seclabel->imagelabel == NULL) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,