From: Peter Krempa Date: Tue, 28 Aug 2012 16:27:31 +0000 (+0200) Subject: security_dac: Avoid segfault when no label is requested X-Git-Tag: v0.10.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2b241e6a76a2b01f002bf1f71ee321b40bd2ee2;p=thirdparty%2Flibvirt.git security_dac: Avoid segfault when no label is requested When no DAC "label" was requested for a domain the DAC manager tried to strdup a NULL string causing a segfault. --- diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 925498fe4c..4162e26b7e 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -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,