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.
This commit is contained in:
Peter Krempa 2012-08-28 18:27:31 +02:00
parent f2bb32b1d2
commit f2b241e6a7

View 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,