virSecurityManagerGenLabel: Skip seclabels without model

While generating seclabels, we check the seclabel stack if required
driver is in the stack. If not, an error is returned. However, it is
possible for a seclabel to not have any model set (happens with LXC
domains that have just <seclabel type='none'>). If that's the case,
we should just skip the iteration instead of calling STREQ(NULL, ...)
and SIGSEGV-ing subsequently.
(cherry picked from commit ba44dd2453)
This commit is contained in:
Michal Privoznik 2013-07-15 15:50:29 +02:00 committed by Doug Goldstein
parent 06e612e9b1
commit c5433874fd

View File

@ -450,6 +450,9 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
virObjectLock(mgr); virObjectLock(mgr);
for (i = 0; i < vm->nseclabels; i++) { for (i = 0; i < vm->nseclabels; i++) {
if (!vm->seclabels[i]->model)
continue;
for (j = 0; sec_managers[j]; j++) for (j = 0; sec_managers[j]; j++)
if (STREQ(vm->seclabels[i]->model, sec_managers[j]->drv->name)) if (STREQ(vm->seclabels[i]->model, sec_managers[j]->drv->name))
break; break;