From f2b241e6a76a2b01f002bf1f71ee321b40bd2ee2 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 28 Aug 2012 18:27:31 +0200 Subject: [PATCH] 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. --- src/security/security_dac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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,