virSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit'

virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that the callers is completely ignoring the error.

Move the length check into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-22 17:26:40 +01:00
parent 33f2cc0712
commit f3a8f26339

View File

@ -8065,9 +8065,10 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDef ***seclabels_rtn,
ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->labelskip)); ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->labelskip));
ctxt->node = list[i]; ctxt->node = list[i];
label = virXPathStringLimit("string(./label)", label = virXPathString("string(./label)", ctxt);
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
seclabels[i]->label = g_steal_pointer(&label); if (label && strlen(label) < VIR_SECURITY_LABEL_BUFLEN)
seclabels[i]->label = g_steal_pointer(&label);
if (seclabels[i]->label && !seclabels[i]->relabel) { if (seclabels[i]->label && !seclabels[i]->relabel) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,